// This example lets the i/o board read an analog input // value, and send it via the serial port. The value that // it sends is coded as a single byte value. // Also, bytes received on the serial port set one of the // connected leds on, and the others low. For example, if // a value 5 is received via the serial port, then led 5 // is set on. void setup() { Serial.begin(9600); // start serial comm at 9600 bps for (int i=0; i<8; i++) { // set digital pins 0-7 as outputs pinMode(i, OUTPUT); } } void loop() { int v = analogRead(0); // read analog input pin 0 Serial.print(v/4, BYTE); // send it via serial port if (Serial.available() > 0) { // if serial data available int p = Serial.read(); // read value p off the serial port for (int i=0; i<8; i++) { if (i == p) { // set pin p HIGH digitalWrite(i, HIGH); } else { digitalWrite(i, LOW); // and all other pins LOW } } } delay(100); }