aboutsummaryrefslogtreecommitdiff
path: root/doc/Lesson 2 Bluetooth Car
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-08-26 20:33:02 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-08-26 20:33:02 +0200
commitba216919262d7f888bfb99debf81babe1ce88e0e (patch)
tree16c19610a7a3a77c97b99a63f6ba85d11ebde4ec /doc/Lesson 2 Bluetooth Car
parentd80736ab6e8e3cad2f1a30c6eaba2d6883dbe967 (diff)
Move lessons to doc
Diffstat (limited to 'doc/Lesson 2 Bluetooth Car')
-rwxr-xr-xdoc/Lesson 2 Bluetooth Car/Bluetooth Car.pdfbin0 -> 743377 bytes
-rwxr-xr-xdoc/Lesson 2 Bluetooth Car/Lesson 2 Bluetooth Car.avibin0 -> 31259028 bytes
-rwxr-xr-xdoc/Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino22
-rwxr-xr-xdoc/Lesson 2 Bluetooth Car/bluetooth_car/bluetooth_car.ino108
-rwxr-xr-xdoc/Lesson 2 Bluetooth Car/com.shenyaocn.android.BlueSPP.apkbin0 -> 1920712 bytes
5 files changed, 130 insertions, 0 deletions
diff --git a/doc/Lesson 2 Bluetooth Car/Bluetooth Car.pdf b/doc/Lesson 2 Bluetooth Car/Bluetooth Car.pdf
new file mode 100755
index 0000000..c5111b6
--- /dev/null
+++ b/doc/Lesson 2 Bluetooth Car/Bluetooth Car.pdf
Binary files differ
diff --git a/doc/Lesson 2 Bluetooth Car/Lesson 2 Bluetooth Car.avi b/doc/Lesson 2 Bluetooth Car/Lesson 2 Bluetooth Car.avi
new file mode 100755
index 0000000..e464cc7
--- /dev/null
+++ b/doc/Lesson 2 Bluetooth Car/Lesson 2 Bluetooth Car.avi
Binary files differ
diff --git a/doc/Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino b/doc/Lesson 2 Bluetooth Car/bluetooth_blink/bluetooth_blink.ino
new file mode 100755
index 0000000..5e357c1
--- /dev/null
+++ b/doc/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();
+ }
+}
diff --git a/doc/Lesson 2 Bluetooth Car/bluetooth_car/bluetooth_car.ino b/doc/Lesson 2 Bluetooth Car/bluetooth_car/bluetooth_car.ino
new file mode 100755
index 0000000..d796348
--- /dev/null
+++ b/doc/Lesson 2 Bluetooth Car/bluetooth_car/bluetooth_car.ino
@@ -0,0 +1,108 @@
+//www.elegoo.com
+//2016.09.12
+
+int LED=13;
+volatile int state = LOW;
+char getstr;
+int in1=9;
+int in2=8;
+int in3=7;
+int in4=6;
+int ENA=10;
+int ENB=5;
+int ABS=135;
+void _mForward()
+{
+ digitalWrite(ENA,HIGH);
+ digitalWrite(ENB,HIGH);
+ digitalWrite(in1,LOW);
+ digitalWrite(in2,HIGH);
+ digitalWrite(in3,LOW);
+ digitalWrite(in4,HIGH);
+ Serial.println("go forward!");
+}
+void _mBack()
+{
+ digitalWrite(ENA,HIGH);
+ digitalWrite(ENB,HIGH);
+ digitalWrite(in1,HIGH);
+ digitalWrite(in2,LOW);
+ digitalWrite(in3,HIGH);
+ digitalWrite(in4,LOW);
+ Serial.println("go back!");
+}
+void _mleft()
+{
+ analogWrite(ENA,ABS);
+ analogWrite(ENB,ABS);
+ digitalWrite(in1,LOW);
+ digitalWrite(in2,HIGH);
+ digitalWrite(in3,HIGH);
+ digitalWrite(in4,LOW);
+ Serial.println("go left!");
+}
+void _mright()
+{
+ analogWrite(ENA,ABS);
+ analogWrite(ENB,ABS);
+ digitalWrite(in1,HIGH);
+ digitalWrite(in2,LOW);
+ digitalWrite(in3,LOW);
+ digitalWrite(in4,HIGH);
+ Serial.println("go right!");
+}
+void _mStop()
+{
+ digitalWrite(ENA,LOW);
+ digitalWrite(ENB,LOW);
+ Serial.println("Stop!");
+}
+void stateChange()
+{
+ state = !state;
+ digitalWrite(LED, state);
+}
+void setup()
+{
+ pinMode(LED, OUTPUT);
+ Serial.begin(9600);
+ pinMode(in1,OUTPUT);
+ pinMode(in2,OUTPUT);
+ pinMode(in3,OUTPUT);
+ pinMode(in4,OUTPUT);
+ pinMode(ENA,OUTPUT);
+ pinMode(ENB,OUTPUT);
+ _mStop();
+}
+void loop()
+ {
+ getstr=Serial.read();
+ if(getstr=='f')
+ {
+ _mForward();
+ }
+ else if(getstr=='b')
+ {
+ _mBack();
+ delay(200);
+ }
+ else if(getstr=='l')
+ {
+ _mleft();
+ delay(200);
+ }
+ else if(getstr=='r')
+ {
+ _mright();
+ delay(200);
+ }
+ else if(getstr=='s')
+ {
+ _mStop();
+ }
+ else if(getstr=='A')
+ {
+ stateChange();
+ }
+}
+
diff --git a/doc/Lesson 2 Bluetooth Car/com.shenyaocn.android.BlueSPP.apk b/doc/Lesson 2 Bluetooth Car/com.shenyaocn.android.BlueSPP.apk
new file mode 100755
index 0000000..71f403e
--- /dev/null
+++ b/doc/Lesson 2 Bluetooth Car/com.shenyaocn.android.BlueSPP.apk
Binary files differ