Created
December 27, 2016 07:58
-
-
Save tomonari-t/d5c5749c79b34eb58d38ad556f153db9 to your computer and use it in GitHub Desktop.
BLESerial3.ino
This file contains hidden or 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
const int PIN_LED = 6; | |
void blinkLED() { | |
digitalWrite(PIN_LED, HIGH); | |
delay(100); | |
digitalWrite(PIN_LED, LOW); | |
} | |
void doubleBlinkLED() { | |
digitalWrite(PIN_LED, HIGH); | |
delay(100); | |
digitalWrite(PIN_LED, LOW); | |
delay(100); | |
digitalWrite(PIN_LED, HIGH); | |
delay(100); | |
digitalWrite(PIN_LED, LOW); | |
} | |
void setup() { | |
pinMode(PIN_LED, OUTPUT); | |
Serial1.begin(9600); | |
} | |
void loop() { | |
// データが送られてきたら | |
if (Serial1.available() > 0) { | |
int data = Serial1.read(); | |
if (data == 1) { | |
blinkLED(); | |
} | |
if (data == 2) { | |
doubleBlinkLED(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment