Created
November 14, 2018 17:03
-
-
Save baobao/a5e65b5f0ed4b5d462d3ab9905b3fdca 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); | |
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