//https://maker.pro/arduino/tutorial/how-to-make-arduino-and-processing-ide-communicate //Learn how to connect the Arduino to the Processing IDE so they can communicate with one another. int led_pin = 7; int pot_pin= 3; int pot_output = 0; #include #define RX 0 #define TX 2 SoftwareSerial Serial(RX,TX); void setup() { // put your setup code here, to run once: pinMode(led_pin,OUTPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: pot_output = analogRead(pot_pin); int mapped_output = map (pot_output, 0, 1023, 0,255); Serial.println(mapped_output); //sending output to processing if (Serial.available ( ) > 0) { // Checking if the Processing IDE has send a value or not char state = Serial.read ( ); // Reading the data received and saving in the state variable if(state == '1') // If received data is '1', then turn on LED { digitalWrite (led_pin, HIGH); } if (state == '0') { // If received data is '0', then turn off led digitalWrite (led_pin, LOW); } } delay(50); }