Skip to content

Instantly share code, notes, and snippets.

@medicalwei
Created February 26, 2011 03:34
Show Gist options
  • Save medicalwei/844907 to your computer and use it in GitHub Desktop.
Save medicalwei/844907 to your computer and use it in GitHub Desktop.
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