-
Notifications
You must be signed in to change notification settings - Fork 0
/
_2wheelrobot5.ino
95 lines (70 loc) · 1.26 KB
/
_2wheelrobot5.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
int mode=0;
int ldr0;
int ldr1;
int ldr2;
int ldr3;
int ldr4;
int ldr5;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(9, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(10, OUTPUT);
motorNoPower();
}
void loop() {
delay(25);
ldr0=analogRead(A0);
ldr1=analogRead(A1);
ldr2=analogRead(A2);
ldr3=analogRead(A3);
ldr4=analogRead(A4);
ldr5=analogRead(A5);
Serial.print(ldr0);
Serial.print(",");
Serial.print(ldr1);
Serial.print(",");
Serial.print(ldr2);
Serial.print(",");
Serial.print(ldr3);
Serial.print(",");
Serial.print(ldr4);
Serial.print(",");
Serial.print(ldr5);
Serial.println("");
if(ldr0<600){
motorNoPower();
debugLedPattern();
return;
}
debugToggleSled();
if(ldr1<600){
motorADir(1);
}else{
motorADir(0);
}
if(ldr2<600){
motorBDir(1);
}else{
motorBDir(0);
}
if(ldr3<600){
motorAPower(0);
}else{
motorAPower(255);
}
if(ldr4<600){
motorBPower(0);
}else{
motorBPower(255);
}
if(ldr5>600){
debugToggleSled12();
}
}