aboutsummaryrefslogtreecommitdiff
path: root/doc/Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino
blob: 5e357c14c5af104213c50fa93331392003ccf49b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//www.elegoo.com
//2016.09.12

int LED=13;//Define 13 pin for LED
volatile int state = LOW;//The initial state of the function is defined as a low level
char getstr;    //Defines a function that receives the Bluetooth character
void setup() {
 pinMode(LED, OUTPUT);
Serial.begin(9600);
}
/*Control LED sub function*/
void stateChange()
{
  state = !state;
  digitalWrite(LED, state);  
}
void loop() {
    getstr=Serial.read();//The Bluetooth serial port to receive the data in the function
    if(getstr=='A'){
    stateChange();
  }
}