Advertisement
Guest User

Untitled

a guest
May 14th, 2012
5,559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. const int ledPin = 13; // the pin that the LED is attached to - change this if you have a separate LED connected to another pin
  2. int incomingByte; // a variable to read incoming serial data into
  3.  
  4. void setup() {
  5. // initialize serial communication:
  6. Serial.begin(9600);
  7. // initialize the LED pin as an output:
  8. pinMode(ledPin, OUTPUT);
  9. }
  10.  
  11. void loop() {
  12. // see if there's incoming serial data:
  13. if (Serial.available() > 0) {
  14. // read the oldest byte in the serial buffer:
  15. incomingByte = Serial.read();
  16. // if it's a capital H (ASCII 72), turn on the LED:
  17. if (incomingByte == 'H') {
  18. digitalWrite(ledPin, HIGH);
  19. }
  20. // if it's an L (ASCII 76) turn off the LED:
  21. if (incomingByte == 'L') {
  22. digitalWrite(ledPin, LOW);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement