#include SoftwareSerial mySerial(5, 6); // RX, TX const int buttonPin = 0; // the number of the pushbutton pin // pins for the LEDs: const int redPin = 3; const int greenPin = 5; const int bluePin = 6; void setup() { //mySerial.begin(9600); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } void loop() { // if there's any serial available, read it: while (mySerial.available() > 0) { // look for the next valid integer in the incoming serial stream: int red = mySerial.parseInt(); // do it again: int green = mySerial.parseInt(); // do it again: int blue = mySerial.parseInt(); // look for the newline. That's the end of your // sentence: if (mySerial.read() == '\n') { // constrain the values to 0 - 255 and invert // if you're using a common-cathode LED, just use "constrain(color, 0, 255);" red = 255 - constrain(red, 0, 255); green = 255 - constrain(green, 0, 255); blue = 255 - constrain(blue, 0, 255); // fade the red, green, and blue legs of the LED: digitalWrite(redPin, red); digitalWrite(greenPin, green); digitalWrite(bluePin, blue); mySerial.println("1"); } } }