For this assignment, I used a potentiometer and the fabduino to transmit data into processing. The aim is to be able to change the brightness of the background in processing (blue color gradients).
Arduino Code:
int potPin= 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int val = map(analogRead(potPin),0,1023,0,233);
Serial.println(val);
delay(50);
}
Processing Code:
import processing.serial.*;
Serial port;
float brightness = 0;
void setup()
{
size (500,500);
port= new Serial(this, "/dev/tty.usbserial-FTGFKIW3", 9600);
port.bufferUntil('\n');
}
void draw()
{
background(0,0,brightness);
}
void serialEvent (Serial port)
{
brightness = float(new String(port.readBytesUntil('\n')));
}