document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // Wiring/Arduino code:
  2. // Read data from the serial and turn ON or OFF a light depending on the value
  3.  
  4. char val; // Data received from the serial port
  5. int ledPin8 = 8; // Set the pin to digital I/O 8
  6. int ledPin9 = 9; // Set the pin to digital I/O 9
  7. int ledPin10 = 10; // Set the pin to digital I/O 10
  8.  
  9. void setup() {
  10. pinMode(ledPin8, OUTPUT); // Set pin as OUTPUT
  11. pinMode(ledPin9, OUTPUT); // Set pin as OUTPUT
  12. pinMode(ledPin10, OUTPUT); // Set pin as OUTPUT
  13. Serial.begin(9600); // Start serial communication at 9600 bps
  14. }
  15.  
  16. void loop() {
  17. if (Serial.available()>0) { // If data is available to read,
  18. val = Serial.read(); // read it and store it in val
  19. }
  20. if (val == 'A') { // If 'A' was received from Processing code
  21. digitalWrite(ledPin8, HIGH); // turn the LED on
  22. }
  23. if (val == 'B') { // If 'B' was received from Processing code
  24. digitalWrite(ledPin8, LOW); // Turn the LED off
  25. }
  26.  
  27. if (val == 'C') { // If 'C' was received from Processing code
  28. digitalWrite(ledPin9, HIGH); // turn the LED on
  29. }
  30. if (val == 'D') { // If 'D' was received from Processing code
  31. digitalWrite(ledPin9, LOW); // Turn the LED off
  32. }
  33.  
  34. if (val =='E') { // If 'E' was received from Processing code
  35. digitalWrite(ledPin10, HIGH); // turn the LED on
  36. }
  37. if (val =='F') {
  38. digitalWrite(ledPin10, LOW); // Turn the LED off
  39. }
  40.  
  41. //delay(10); // Wait 100 milliseconds for next reading
  42. }
');