/* * Serial RGB LED TOO * ------------------ * Serial commands control the brightness of R,G,B LEDs * * Command structure is "#RRGGBB" * * * Created 18 October 2006 * copyleft 2006 Tod E. Kurt >16); Serial.print(" g:"); Serial.print((colorVal&0x00ff00)>>8); Serial.print(" b:"); Serial.println((colorVal&0x0000ff)>>0); memset(serInStr,0,slen); // indicates we've used this string //spos = 0; analogWrite(redPin, (colorVal&0xff0000)>>16 ); analogWrite(greenPin, (colorVal&0x00ff00)>>8 ); analogWrite(bluePin, (colorVal&0x0000ff)>>0 ); } delay(200); // wait a bit, for serial data } //read a string from the serial and store it in an array int readSerialString () { int i=0; if(!Serial.available()) { return -1; } while (Serial.available() && i < slen) { int c = Serial.read(); serInStr[i++] = c; } Serial.println(serInStr); return i; }