/* Arduino and RGB Control using Processing https://www.himix.lt/arduino/arduino-and-rgb-control-processing/ based on: https://gist.github.com/atduskgreg/1349176 */ /* - Red Led to digital pin 6 - Green Led to digital pin 5 - Blue Led: to digital pin 3 */ //#include //#define rxPin 0 //#define txPin 1 //SoftwareSerial mySerial(rxPin, txPin); int currentValue = 0; int values[] = {0,0}; //boolean ledState = LOW; //to toggle our LED // pins for the LEDs: const int redPin = 6; const int greenPin = 5; //const int bluePin = 3; void setup() { // initialize serial: Serial.begin(9600); // make the pins outputs: pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); //pinMode(bluePin, OUTPUT); } void loop() { if (Serial.available() > 0) { // if there's any serial available, read it: int incomingValue = Serial.read(); values[currentValue] = incomingValue; currentValue++; if(currentValue > 1){ analogWrite(redPin, values[0]); analogWrite(greenPin, values[1]); //analogWrite(bluePin, values[2]); currentValue = 0; } } }