Created
February 26, 2011 03:34
-
-
Save medicalwei/844907 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() | |
{ | |
Serial.begin(9600); // Use serial with 9600 baud rate | |
pinMode(13, OUTPUT); | |
} | |
void loop() | |
{ | |
if(Serial.available()) // Check if there is something for Arduino to read | |
{ | |
char a = Serial.read(); // Read a character | |
switch(a) | |
{ | |
case '0': | |
digitalWrite(13, LOW); | |
break; | |
case '1': | |
digitalWrite(13, HIGH); | |
break; | |
case '2': | |
if(digitalRead(13) == HIGH) | |
{ | |
Serial.print('1'); // Write a character to serial port | |
} | |
else | |
{ | |
Serial.print('0'); | |
} | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment