From 6eb77fdf18616f79f99f2a57eed40d3b7a55eaa5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 2 Jan 2017 09:24:18 +0100 Subject: Initial import --- .../bluetooth_blink/bluetooth_blink.ino | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino (limited to 'Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino') diff --git a/Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino b/Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino new file mode 100755 index 0000000..5e357c1 --- /dev/null +++ b/Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino @@ -0,0 +1,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(); + } +} -- cgit v1.2.3