From ba216919262d7f888bfb99debf81babe1ce88e0e Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 26 Aug 2017 20:33:02 +0200 Subject: Move lessons to doc --- .../bluetooth_car/bluetooth_car.ino | 108 --------------------- 1 file changed, 108 deletions(-) delete mode 100755 Lesson 2 Bluetooth Car/bluetooth_car/bluetooth_car.ino (limited to 'Lesson 2 Bluetooth Car/bluetooth_car') diff --git a/Lesson 2 Bluetooth Car/bluetooth_car/bluetooth_car.ino b/Lesson 2 Bluetooth Car/bluetooth_car/bluetooth_car.ino deleted file mode 100755 index d796348..0000000 --- a/Lesson 2 Bluetooth Car/bluetooth_car/bluetooth_car.ino +++ /dev/null @@ -1,108 +0,0 @@ -//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(); - } -} - -- cgit v1.2.3