-
Notifications
You must be signed in to change notification settings - Fork 1
/
IARRC.ino
44 lines (42 loc) · 836 Bytes
/
IARRC.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
void setup() {
// put your setup code here, to run once:
pinMode(10 ,OUTPUT);
pinMode(9 ,OUTPUT);
pinMode(8 ,OUTPUT);
pinMode(7,OUTPUT);
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0)
{
int value=Serial.read();
if(value==3){
//forward
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
digitalWrite(8,HIGH);
digitalWrite(7,LOW);
}
else if (value==2){
//left
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,HIGH);
}
else if(value==1){
//right
digitalWrite(10,LOW);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,LOW);
}
else {
//do nothing
digitalWrite(10,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW)
}
}