Skip to content

Instantly share code, notes, and snippets.

@tomonari-t
Created December 27, 2016 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomonari-t/d5c5749c79b34eb58d38ad556f153db9 to your computer and use it in GitHub Desktop.
Save tomonari-t/d5c5749c79b34eb58d38ad556f153db9 to your computer and use it in GitHub Desktop.
BLESerial3.ino
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