Skip to content

Instantly share code, notes, and snippets.

@baobao
Created November 14, 2018 17:03
Show Gist options
  • Save baobao/a5e65b5f0ed4b5d462d3ab9905b3fdca to your computer and use it in GitHub Desktop.
Save baobao/a5e65b5f0ed4b5d462d3ab9905b3fdca to your computer and use it in GitHub Desktop.
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
// シリアル通信でデータが送られてくるまで待つ。
if (Serial.available() > 0)
{
// 一文字分データを取り出す。
char c = Serial.read();
if (c == 'n')
{
// nが送られてきたらLEDを点灯させる。
digitalWrite(13, HIGH);
}
else if(c == 'f')
{
// fが送られてきたらLEDを消灯させる。
digitalWrite(13, LOW);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment