Presentation is loading. Please wait.

Presentation is loading. Please wait.

Arduino UMBC IEEE Sekar Kulandaivel

Similar presentations


Presentation on theme: "Arduino UMBC IEEE Sekar Kulandaivel "— Presentation transcript:

1 Arduino Microcontroller Workshop UMBC Institute of Electrical and Electronics Engineers
Arduino UMBC IEEE Sekar Kulandaivel Week 2: Communication with Processing Technical Skills Series Presentation April 10th, 2014

2 Processing Download: https://processing.org/download/?processing
Why Processing? Visual feedback Alternative method of communication Opens doors for a variety of projects

3 Important Arduino Functions
int val, time; void setup() { … } void loop() { … } Serial.begin(9600); Serial.print(“Hello”); Serial.println(val); delay(1000); pinMode(8, INPUT); pinMode(9, OUTPUT); val = digitalRead(8); digitalWrite(9, out); val = analogRead(A0); analogWrite(9, out); time = millis(); map(var, testLow, testHigh, mapLow, mapHigh);

4 const int piezoPin = A4; const int photoPin = A5; int incoming, piezoValue, photoValue; void setup() { Serial.begin(9600); while (!Serial) { // do nothing } establishContact();

5 void loop() { if (Serial. available() > 0) { incoming = Serial
void loop() { if (Serial.available() > 0) { incoming = Serial.read(); piezoValue = analogRead(piezoPin) / 4; delay(10); photoValue = analogRead(photoPin) / 4; Serial.write(piezoValue); Serial.write(photoValue); } void establishContact() { while (Serial.available() <= 0) { Serial.print('X'); delay(300);

6 import processing. serial
import processing.serial.*; Serial port; int bgcolor, fgcolor; int[] serialInput = new int[2]; int serialCount = 0; int xpos, ypos, size; boolean contact = false; void setup() { size(400, 400); noStroke(); xpos = 200; ypos = 200; size = 20; String arduino = Serial.list()[0]; port = new Serial(this, arduino, 9600); }

7 void draw() { background(bgcolor); fill(fgcolor); ellipse(xpos, ypos, size, size); }

8 void serialEvent(Serial port) { int incoming = port
void serialEvent(Serial port) { int incoming = port.read(); if (contact == false) { if (incoming == 'X') { port.clear(); contact = true; port.write('X'); } } else { serialInput[serialCount] = incoming; serialCount++; if (serialCount > 1) { size = serialInput[0]; fgcolor = serialInput[1]; println(size + "\t" + fgcolor); serialCount = 0;

9 Piezoelectric Sensor Analog Resistors: 1MΩ

10 Photoresistor and Potentiometer

11 Goals for Today Create a photoresistor array. Create a virtual RGB LED. Create a program that responds to sound. Any more ideas?


Download ppt "Arduino UMBC IEEE Sekar Kulandaivel "

Similar presentations


Ads by Google