-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhc05-esp-l298n.ino
60 lines (54 loc) · 1.07 KB
/
hc05-esp-l298n.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
char data;
#define M1_1 D5
#define M1_2 D6
#define M2_1 D7
#define M2_2 D8
void setup(){
pinMode(M1_1, OUTPUT);
pinMode(M1_2, OUTPUT);
pinMode(M2_1, OUTPUT);
pinMode(M2_2, OUTPUT);
Serial.begin(9600);
}
void loop(){
if (Serial.available()){
char data;
data = Serial.read();
Serial.println(data);
if(data=='F')
{
digitalWrite(M1_1,LOW);
digitalWrite(M1_2,HIGH);
digitalWrite(M2_1,HIGH);
digitalWrite(M2_2,LOW);
}
if(data=='B')
{
digitalWrite(M1_1,HIGH);
digitalWrite(M1_2,LOW);
digitalWrite(M2_1,LOW);
digitalWrite(M2_2,HIGH);
}
if(data=='L')
{
digitalWrite(M1_1,HIGH);
digitalWrite(M1_2,LOW);
digitalWrite(M2_1,HIGH);
digitalWrite(M2_2,LOW);
}
if(data=='R')
{
digitalWrite(M1_1,LOW);
digitalWrite(M1_2,HIGH);
digitalWrite(M2_1,LOW);
digitalWrite(M2_2,HIGH);
}
if(data=='S')
{
digitalWrite(M1_1,LOW);
digitalWrite(M1_2,LOW);
digitalWrite(M2_1,LOW);
digitalWrite(M2_2,LOW);
}
}
}