Skip to content

Instantly share code, notes, and snippets.

@starlightme
Last active October 15, 2015 14:54
Show Gist options
  • Save starlightme/2deaa34c72548f57dbb1 to your computer and use it in GitHub Desktop.
Save starlightme/2deaa34c72548f57dbb1 to your computer and use it in GitHub Desktop.
串口通信-- Arduino端
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
int led = 1;
void loop()
{
if(Serial.available())
{
Serial.read();
led = 1 - led;
if(led > 0)
{
digitalWrite(13, LOW);
}
else
{
digitalWrite(13, HIGH);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment