DMS 8013: No words

IMG_20160506_202258377

I did this work before the Post-it messages one but I didn’t upload it till now. It is also a piece of work based in serial communication between Arduino and Processing.

No words is is an interactive communication between Arduino and Processing, which purpose is to replace the used of words. Basically Arduino has a potentiometer that send data from it to Processing, which converts the data in a graphic. 

See the result below

– the Potentiometer works well with the software

YouTube Preview Image

– the Graphic processing

YouTube Preview Image

See below the code:

ARDUINO

void setup() {
// initialize the serial communication:
Serial.begin(9600);
}

void loop() {
// send the value of analog input 0:
Serial.println(analogRead(A0));
Serial.print(analogRead(A1));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(10);
}

PROCESSING
import processing.serial.*;
float xPos = 0; // horizontal position of the graph
float yPos = 0; // vertical position of the graph

Serial myPort;
// change the number below to match your port:
String portName = Serial.list()[2];
void setup () {
size(600,600);
myPort = new Serial(this, portName, 9600);

}

 

void serialEvent (Serial myPort) {
// get the byte:
int inByte = myPort.read();
// print it:
println(inByte);
yPos = height – inByte;
}
void draw () {
background(#024540);
// draw the line in a pretty color:
stroke(#F4D9A7);
line(xPos, height, xPos, yPos);
line(xPos, height, xPos, yPos);
// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
// clear the screen by resetting the background:

} else {
// increment the horizontal position for the next reading:
xPos++;
}
}

* Obviously this code is not mine. But if I am honest, I don’t remember the exact source where I took it from as I have been checking many websites, many different codes, I’ve been constantly changing the code, so I think the best thing to do is to post the link I used as a reference:

https://itp.nyu.edu/physcomp/labs/labs-serial-communication/serial-output-from-an-arduino/

https://arduining.com/2013/08/05/arduino-and-processing-graph-example/