// Arduino IDE: // File -> Examples -> 04.Communication -> PhysicalPixel #define myservo 5 // the pin the servo is on int incomingByte; // variable stores serial data void setup() { // initialize serial communication: Serial.begin(115200); // initialize the LED pin as an output: pinMode(myservo, OUTPUT); } void loop() { // see if there's incoming serial data: if (Serial.available() > 0) { // read the oldest byte in the serial buffer: incomingByte = Serial.read(); // if it's a capital H (ASCII 72), turn on the LED: if (incomingByte == 'H') { for (int x = 0; x < 50; x++) { digitalWrite(myservo, HIGH); delayMicroseconds(500); digitalWrite(myservo, LOW); delayMicroseconds(19500); } Serial.println("Getting H"); //print out to serial monitor to check state } // if it's an L (ASCII 76) turn off the LED: if (incomingByte == 'L') { for (int x = 0; x < 50; x++) { digitalWrite(myservo, HIGH); delayMicroseconds(2500); digitalWrite(myservo, LOW); delayMicroseconds(17500); } Serial.println("Getting L"); //print out to serial monitor to check state } } }