-
Notifications
You must be signed in to change notification settings - Fork 1
/
arduino_main.ino
99 lines (80 loc) · 1.6 KB
/
arduino_main.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//MOTOR1 PINS
int ena = 9;
int in1 = 3;
int in2 = 4;
int enb = 10;
int in4 = 5;
int in3 = 6;
#define del 100
void setup() {
pinMode(ena, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(enb, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0)
{
char a=Serial.read();
Serial.println(a);
if (a=='f')
{
analogWrite(ena, 255);
analogWrite(enb, 255);
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
delay(110);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
}
if (a=='b')
{
analogWrite(ena, 255);
analogWrite(enb, 255);
digitalWrite(in2,HIGH);
digitalWrite(in1,LOW);
digitalWrite(in4,HIGH);
digitalWrite(in3,LOW);
delay(110);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
}
if (a=='l')
{
analogWrite(ena, 255);
analogWrite(enb, 255);
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
delay(50);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
}
if (a=='r')
{
analogWrite(ena, 255);
analogWrite(enb, 255);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
delay(50);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
}
}
}