/* Physical Pixel Experiment to see if I can control the LEDs on my Satshsakit board */ #define LED1Pin 2 // the pin for LED1 #define LED2Pin 3 // the pin for LED2 #define LED3Pin 4 // the pin for LED3 #define LED4Pin 5 // the pin for LED4 #define LED5Pin 6 // the pin for LED5 #define LED6Pin 7 // the pin for LED6 int incomingByte; // a variable to read incoming serial data into void setup() { // Initialize serial communication: Serial.begin(9600); // Initialize the LED pins as outputs: pinMode(LED1Pin, OUTPUT); pinMode(LED2Pin, OUTPUT); pinMode(LED3Pin, OUTPUT); pinMode(LED4Pin, OUTPUT); pinMode(LED5Pin, OUTPUT); pinMode(LED6Pin, OUTPUT); } void loop() { digitalWrite(LED1Pin, HIGH); if (Serial.available() > 0) { // see if there's incoming serial data: digitalWrite(LED2Pin, HIGH); incomingByte = Serial.read(); // read the oldest byte in the serial buffer: if (incomingByte == 'H1') { // if it's H1 (ASCII 72), turn on the LED1Pin digitalWrite(LED1Pin, HIGH); } if (incomingByte == 'L1') { // if it's L1 (ASCII 76), turn off the LED1Pin digitalWrite(LED1Pin, LOW); } if (incomingByte == 'H2') { // if it's H2 (ASCII 72), turn on the LED2Pin digitalWrite(LED2Pin, HIGH); } if (incomingByte == 'L2') { // if it's L2 (ASCII 76), turn off the LED2Pin digitalWrite(LED2Pin, LOW); } if (incomingByte == 'H3') { // if it's H3 (ASCII 72), turn on the LED3Pin digitalWrite(LED3Pin, HIGH); } if (incomingByte == 'L3') { // if it's L3 (ASCII 76), turn off the LED3Pin digitalWrite(LED3Pin, LOW); } if (incomingByte == 'H4') { // if it's H4 (ASCII 72), turn on the LED4Pin digitalWrite(LED4Pin, HIGH); } if (incomingByte == 'L4') { // if it's L4 (ASCII 76), turn off the LED4Pin digitalWrite(LED4Pin, LOW); } if (incomingByte == 'H5') { // if it's H5 (ASCII 72), turn on the LED5Pin digitalWrite(LED5Pin, HIGH); } if (incomingByte == 'L5') { // if it's L5 (ASCII 76), turn off the LED5Pin digitalWrite(LED5Pin, LOW); } if (incomingByte == 'H6') { // if it's H6 (ASCII 72), turn on the LED6Pin digitalWrite(LED6Pin, HIGH); } if (incomingByte == 'L6') { // if it's L6 (ASCII 76), turn off the LED6Pin digitalWrite(LED6Pin, LOW); } } }