Hello!
I am trying to send info from arduino to processing but my code is not working, it worked before! =[
Does the board need to be plugged in to work?
Can someone please explain whats wrong?
Processing Code
import processing.serial.*;
Serial port;
int val;
void setup(){
size(200, 200);
println(Serial.list());
String arduinoPort = Serial.list()[0];
port = new Serial(this, arduinoPort, 9600);
}
void draw()
{
background(128);
if(port.available()>0)
{
val = port.read();
println(val);
if(val == 1)
{
fill(255,0,0);
}
if(val == 0)
{
fill(0,255,0);
}
}
ellipse(100, 100, 30,30);
}
Arduino code
int val;
void setup() {
pinMode(6, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
val = digitalRead(6);
//Serial.println(val);
Serial.write(val);
delay(100);
}
Thank you!