1
7
8#include <SoftwareSerial.h>
9
10SoftwareSerial blueToothSerial(0, 1);
11
12int IN1 = 9;
13int IN2 = 10;
14int IN3 = 11;
15int IN4 = 12;
16int ENA = 6;
17int ENB = 5;
18char t;
19
20
26
27void setup() {
28 pinMode(IN1, OUTPUT);
29 pinMode(IN2, OUTPUT);
30 pinMode(IN3, OUTPUT);
31 pinMode(IN4, OUTPUT);
32 pinMode(ENA, OUTPUT);
33 pinMode(ENB, OUTPUT);
34 Serial.begin (9600);
35}
36
37void loop() {
38 while (Serial.available() > 0) {
39 t = Serial.read();
40 }
41
42 Serial.println (t);
43
44 switch (t) {
45 case 'F':
46 digitalWrite(ENA, HIGH);
47 digitalWrite(ENB, HIGH);
48 digitalWrite(IN4, HIGH);
49 digitalWrite(IN3, LOW);
50 digitalWrite(IN2, HIGH);
51 digitalWrite(IN1, LOW);
52 break;
53 case 'B':
54 digitalWrite(ENA, HIGH);
55 digitalWrite(ENB, HIGH);
56 digitalWrite(IN4, LOW);
57 digitalWrite(IN3, HIGH);
58 digitalWrite(IN2, LOW);
59 digitalWrite(IN1, HIGH);
60 break;
61 case 'L':
62 digitalWrite(ENA, HIGH);
63 digitalWrite(ENB, LOW);
64 digitalWrite(IN4, LOW);
65 digitalWrite(IN3, LOW);
66 digitalWrite(IN2, HIGH);
67 digitalWrite(IN1, LOW);
68 break;
69 case 'R':
70 digitalWrite(ENA, LOW);
71 digitalWrite(ENB, HIGH);
72 digitalWrite(IN4, HIGH);
73 digitalWrite(IN3, LOW);
74 digitalWrite(IN2, LOW);
75 digitalWrite(IN1, LOW);
76 break;
77 case 'S':
78 digitalWrite(ENA, LOW);
79 digitalWrite(ENB, LOW);
80 digitalWrite(IN4, LOW);
81 digitalWrite(IN3, LOW);
82 digitalWrite(IN2, LOW);
83 digitalWrite(IN1, LOW);
84 break;
85 }
86}