-
Notifications
You must be signed in to change notification settings - Fork 0
/
Capstone_Project_IEEE_OPS.ino
720 lines (565 loc) · 20 KB
/
Capstone_Project_IEEE_OPS.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
//as of now this is just a mere copy of project 5. make sure i can detect walls, using analog read if necessray. i can techincally bring this home for some tests later.
//serial monitor to double check and use prints for sure.
//the new plan is to no longer rely on IR2, that guy is no longer salvageable.
//also, we can remap so values are nicer, but for now, will completely ignore left sensor. coorection left and turning left will mean looking at the right sensor only, if it drops too much while turning,
//then we have to turn back to the left. if im approaching a wall in ir led1, i will have to turn right or left.
//1. turn right is if irled 3 is signalling NOTHING THERE
//2, turn left is if irled 3 is signalling SOMETHING THERE and ir 1 is tryign to turn
//pray in the 8.1 x2 batteries
//pray in the 8.2V
#define IRLED1 A5 //left
//#define IRLED2 A3 //the A5 and A3 for analog, but the digital ones don't need it
#define IRReceiver1 // only working w/ 1 IR led and 1 Receiver.
#define IRLED2 A6 //left
#define IRLED3 A4 //the A5 and A3 for analog, but the digital ones don't need it
#define IRReceiver2 // only working w/ 1 IR led and 1 Receiver.
//#define IRLED2 A3 //the A5 and A3 for analog, but the digital ones don't need it
#define IRReceiver3 // only working w/ 1 IR led and 1 Receiver.
#define LeftMotor 10 // Enable Pin for motor 1 , using A4 analog write , 1-2 enable pin, should go to A3
#define RightMotor 6 // Enable Pin for motor 2, using A3 , 3-4 enable pin , should go to A 6
#define Right1 2 // Control pin 1 for motor 1, D8 in1
#define Right2 3 // Control pin 2 for motor 1, D9 in2
#define Left1 5 // Control pin 1 for motor 2, D2 in 3
#define Left2 4 // Control pin 2 for motor 2, D3 in4
double KI = 3, KD = 3, KP = 5; //You will be tuning these constants
double integralRight;
double pErrorRight;
int dt = 2;
double integralLeft;
double pErrorLeft;
//TURNING CONSTANTS DELAY for turning
int RightTurnDelay=1225 ; //90degree right turn
//9V 1st guess: 820 //Oldcode 975
int LeftTurnDelay=1260; //90 degree left turn
//9V 1st guess: 835 //Old code 1000
//INIT SPEEDS
int LeftMotorSpeed=125;
int RightMotorSpeed=153;
// analogWrite(LeftMotor, 125);
//analogWrite(RightMotor, 153);
//default, LeftWheel>>>>RightWheel
//PID SPEEDUP CONFIGS RIGHT TURN
//want your right wheel to be > than ur left wheel.
int RHSRightTurnSpeed=133;
//9V 1st guess: 120 //Old code: 133
int LHSRightTurnSpeed=100;
//9V 1st guess: 90 //Old code 100
//PID SPEEDUP CONFIGS LEFT TURN
//want your left wheel to be > than ur right wheel.
int RHSLeftTurnSpeed=100;
//9V 1st guess:88//Old code 100
int LHSLeftTurnSpeed=150;
//9V 1st guess:130 //Old code 150
int idealRight = 22;
int idealLeft = 29;
int errorRight;
int errorLeft;
int derivativeRight;
int derivativeLeft;
int countstuck=0;
//A PID controller
/*
what im realizing here is...
1. values from IR sensor reads are diff
2. values from motor for turning are also going to be diff
(IOW testing these only really possible if in lab...)
*/
bool theEnd=false;
//if too close to one of the walls, we need to turn and check if its too close with some kind of mapping.
int countleft = 0;
int countright = 0;
//#define IRReceiver2
int zerofront;
int zerorear;
//pulse width modulation analog for digital ports : 3,5,6,9,10,11
//analogWrite goes from 0-255
//analogRead goes from 0-1023 though, so we need to map that later.
void setup() {
pinMode(Right1, OUTPUT);
pinMode(Right2, OUTPUT);
pinMode(Left1, OUTPUT);
pinMode(Left2, OUTPUT);
Serial.begin(9600);
// put your setup code here, to run once:
pinMode(IRLED1, INPUT);
pinMode(IRLED2, INPUT);
pinMode(IRLED3, INPUT);
//pinMode(IRRECEIVER1, INPUT); we don't define receivers.
//pinMode(IRRECEIVER1, INPUT);
//analogWrite(LeftMotor, 80);
// analogWrite(RightMotor, 100);
//560 is the highest value consistently ish ive been getting.
}
//LED should get brighter the closer your hand is to the IR receiver.
void loop()
{
// if(countleft>=300)
/* {
Serial.println("RATIO OF COUNT LEFT TO COUNT RIGHT IS");
Serial.println("COUNTLEFT COUNT");
Serial.println(countleft);
Serial.println("COUNTRIGHT COUNT");
Serial.println(countright);
}
*/
if(theEnd) //this is good, when it reaches a dead end, he completelySTOPPSSSS
{
Serial.println("STOPPING CAR BECAUSE APPROACHING WALL BUT PATH EXISTS ON BOTH SIDES");
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, HIGH);
//end of the maze bool condition
delay(2000);
return;
}
analogWrite(LeftMotor, LeftMotorSpeed);
analogWrite(RightMotor, RightMotorSpeed);
//high is to activiate and turn it
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
int IR1 = analogRead(IRLED1);
int LED1V = map(IR1, 0, 1023, 255, 0); // starts at 196 -> 18->20 is too close, 50 is turn. dont have to worry about ideal for front.
//int sum = 0;
int IR2=analogRead(IRLED2);
int LED2V = map(IR2, 0, 1023, 255, 0); //starts at 188->78-85 is too close, 108 is probably an ideal.
int IR3 = analogRead(IRLED3); //starts at 194, -> 20, too close, 50 is ideal
int LED3V = map(IR3, 0, 1023, 255, 0);
//243 is intial value.
//129, 135
//int LED1V=IR1;
//int LED2V=IR2;
///int LED3V=IR3;
//Serial.println("IR1 is ");
// Serial.println(LED1V);
//Serial.println("IR2 is ");
//Serial.println(LED2V);
if (LED1V <= 15) //front
{
analogWrite(LeftMotor, LeftMotorSpeed);
analogWrite(RightMotor, RightMotorSpeed);
//high is to activiate and turn it
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
//delay();
//delay 2000 and pause first
if(LED2V<50&&LED3V<50)
{
// Serial.println("STOPPING CAR BECAUSE APPROACHING WALL BUT PATH EXISTS ON BOTH SIDES");
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, HIGH);
//end of the maze bool condition
theEnd=true;
delay(2000);
return;
}
if (LED2V <80&&LED3V>165) //should we put a while instead?
//instead of checking if led3V > led2V, check if LED 3 is greater than a certain value, MAKE SURE LED3V IS SMALL. LED 2 had to be small at first b/c wall approach, and we must turn right.
{ //sometimes, the value is at 112...
analogWrite(LeftMotor, 85);
analogWrite(RightMotor, 95);
digitalWrite(Right1, LOW);
digitalWrite(Right2, HIGH);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
int LED2prev=map(analogRead(IRLED2),0,1023,255,0);
int count =0;
delay(120);
while (map(analogRead(IRLED2), 0, 1023, 255, 0) > LED2prev)
{
// Serial.println("In while loop for left sensor");
LED2prev =0;
for(int i =0; i < 5; i++)
LED2prev += map(analogRead(IRLED2),0,1023,255,0);
LED2prev /= 5;
count++;
if(count>1000)
{
//jolt back
analogWrite(LeftMotor,150);
analogWrite(RightMotor,173);
digitalWrite(Right1, LOW);
digitalWrite(Right2, HIGH);
digitalWrite(Left1, LOW);
digitalWrite(Left2, HIGH);
count=0;
}
}
delay(120);
while (map(analogRead(IRLED2), 0, 1023, 255, 0) < LED2prev)
{
// Serial.println("In while loop for left sensor");
LED2prev =0;
for(int i =0; i < 5; i++)
LED2prev += map(analogRead(IRLED2),0,1023,255,0);
LED2prev /= 5;
count++;
if(count>1000)
{
//jolt back
analogWrite(LeftMotor,150);
analogWrite(RightMotor,173);
digitalWrite(Right1, LOW);
digitalWrite(Right2, HIGH);
digitalWrite(Left1, LOW);
digitalWrite(Left2, HIGH);
count=0;
}
}
/* while (map(analogRead(IRLED1), 0, 1023, 255, 0) < 105)
{
// Serial.println("In while loop for front sensor");
}
while (map(analogRead(IRLED2), 0, 1023, 255, 0) > 127)
{
// Serial.println("In while loop for right sensor");
}
*/
//Serial.println("TURN RighT"); //right sensor
analogWrite(LeftMotor, 0);
analogWrite(RightMotor, 0);
}
else if (LED3V < 80&&LED2V>165) //else if LED 3 is greater than a certain value, for turn left, you want to make sure that the right LED value is BIGGGGGG
{
analogWrite(LeftMotor, 85);
analogWrite(RightMotor, 95);
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, HIGH);
int LED3prev=map(analogRead(IRLED3),0,1023,255,0);
/*
while (map(analogRead(IRLED1), 0, 1023, 255, 0) < 105)
{
Serial.println("In while loop for front sensor");
}*/
int count=0;
delay(120);
while (map(analogRead(IRLED3), 0, 1023, 255, 0) > LED3prev)
{
// Serial.println("In while loop for left sensor");
LED3prev =0;
for(int i =0; i < 5; i++)
LED3prev += map(analogRead(IRLED3),0,1023,255,0);
LED3prev /= 5;
count++;
if(count>1000)
{
//jolt back
analogWrite(LeftMotor,150);
analogWrite(RightMotor,173);
digitalWrite(Right1, LOW);
digitalWrite(Right2, HIGH);
digitalWrite(Left1, LOW);
digitalWrite(Left2, HIGH);
count=0;
}
}
delay(120);
while (map(analogRead(IRLED3), 0, 1023, 255, 0) < LED3prev)
{
// Serial.println("In while loop for left sensor");
LED3prev =0;
for(int i =0; i < 5; i++)
LED3prev += map(analogRead(IRLED3),0,1023,255,0);
LED3prev /= 5;
}
Serial.println("TURN LEfT"); //right sensor
analogWrite(LeftMotor, 0);
analogWrite(RightMotor, 0);
count++;
if(count>1000)
{
//jolt back
analogWrite(LeftMotor,150);
analogWrite(RightMotor,173);
digitalWrite(Right1, LOW);
digitalWrite(Right2, HIGH);
digitalWrite(Left1, LOW);
digitalWrite(Left2, HIGH);
count=0;
}
}
/*
errorLeft = idealLeft - LED2V; //correct to the left as a result because we are too close to the right here.
errorRight = idealRight - LED3V-errorLeft; //correct to the left as a result because we are too close to the right here.
derivativeRight = (pErrorRight - errorRight) / dt;
integralRight = errorRight * dt;
pErrorRight = errorRight;
//Serial.print("Error right: ");
//Serial.println(errorRight);
double CorrectionRight = KP * errorRight + KI * integralRight + KD * derivativeRight;
//Serial.println("CORRECTIONRIGHT VALUE ");
//Serial.println(CorrectionRight);
//turn right move forwars a bit. if neg
// Serial.println("LED3V VALUE IS :");
// Serial.println(LED3V);
// Serial.println("CORRECTIONLEFT VALUE ");
// Serial.println(CorrectionLeft);
//turn left move forard a bit.
if (CorrectionRight < 0) //idk have to find out what this value is.
{ //idea is correctionright tooooooo big, we know we need to turn back
//by turning left . if too small too negative, turn back by turn right
//Serial.println("PID TURN LEFT"); //too close to right.
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
analogWrite(RightMotor, 100+CorrectionRight);
analogWrite(LeftMotor, 80-CorrectionRight);
// delay(80);
countleft++;
//delay(500);
}
//Serial.println("CORRECTIONLEFT VALUE ");
//Serial.println(CorrectionLeft);
if(CorrectionRight>0)
{
// Serial.println("PID TURN RIGHT"); //too close to left
countright++;
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
analogWrite(LeftMotor, 80+CorrectionRight);
analogWrite(RightMotor, 100-CorrectionRight); //slow down right motor.
//high is to activiate and turn it
// delay(80);
}
*/
}
//129, 135
//PID CONTROL RIGHT
else if(LED3V<140&&LED2V<140) //do pid
{ //both sensors should be like under 90. but in the case they AINT UNDER 90, one side of the wall is MISSING.
/*
3) If both left/right walls are missing, pretend that you are straight and go forward with the current speed for a
set amount of time until you encounter both walls/one wall again :D (we might take this out if not enough teams can get it done)
*/
//a condition to check for is if there are open walls. how do i counter that problem?
//coorectionright computation
//coorectionright computation
errorRight = idealRight - LED3V; //correct to the left as a result because we are too close to the right here.
derivativeRight = (pErrorRight - errorRight) / dt;
integralRight = errorRight * dt;
pErrorRight = errorRight;
double CorrectionRight = KP * errorRight + KI * integralRight + KD * derivativeRight;
errorLeft = idealLeft - LED2V; //correct to the left as a result because we are too close to the right here.
derivativeLeft = (pErrorLeft - errorLeft) / dt;
integralLeft = errorRight * dt;
pErrorLeft = errorLeft;
double CorrectionLeft = KP * errorLeft + KI * integralLeft + KD * derivativeLeft;
// Serial.println("CORRECTIONRIGHT VALUE ");
// Serial.println(CorrectionRight);
//turn right move forwars a bit. if neg
// Serial.println("LED3V VALUE IS :");
// Serial.println(LED3V);
// Serial.println("CORRECTIONLEFT VALUE ");
// Serial.println(CorrectionLeft);
//turn left move forard a bit.
if (CorrectionRight > CorrectionLeft) //idk have to find out what this value is.
{ //idea is correctionright tooooooo big, we know we need to turn back
//by turning left . if too small too negative, turn back by turn right
// Serial.println("PID TURN LEFT"); //too close to right.
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
analogWrite(RightMotor, 113);
analogWrite(LeftMotor, 0);
delay(35);
countleft++;
//delay(500);
}
//Serial.println("CORRECTIONLEFT VALUE ");
//Serial.println(CorrectionLeft);
if(CorrectionLeft>CorrectionRight)
{
// Serial.println("PID TURN RIGHT"); //too close to left
countright++;
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
analogWrite(LeftMotor, 105);
analogWrite(RightMotor, 0); //slow down right motor.
//high is to activiate and turn it
delay(35);
}//inside this part of pid i should also be checking led 1 for reals though tbh based on how i pid or else make sure when i turn back to normal, I AINT LEANING AGAINST NO WALL. and tryna ram a wall.
}
else if(LED3V>140&&LED2V<140) //missing wall on the right side, do pid only on the left
{
errorLeft = idealLeft - LED2V; //correct to the left as a result because we are too close to the right here.
derivativeLeft = (pErrorLeft - errorLeft) / dt;
integralLeft = errorRight * dt;
pErrorLeft = errorLeft;
double CorrectionLeft = KP * errorLeft + KI * integralLeft + KD * derivativeLeft;
//Serial.println("CORRECTIONLEFT VALUE ");
//Serial.println(CorrectionLeft);
if(CorrectionLeft>0)
{
/* Serial.println("PID TURN RIGHT"); //too close to left
countright++;
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
analogWrite(LeftMotor, 105);
analogWrite(RightMotor, 0); //slow down right motor.
//high is to activiate and turn it
delay(100);
*/
delay(25);
}//inside this part of pid i should also be checking led 1 for reals though tbh based on how i pid or else make sure when i turn back to normal, I AINT LEANING AGAINST NO WALL. and tryna ram a wall.
}
else if(LED2V>140&&LED3V<140) //missing a wall on the left side, do pid only on the right.
{
//coorectionright computation
errorRight = idealRight - LED3V; //correct to the left as a result because we are too close to the right here.
derivativeRight = (pErrorRight - errorRight) / dt;
integralRight = errorRight * dt;
pErrorRight = errorRight;
double CorrectionRight = KP * errorRight + KI * integralRight + KD * derivativeRight;
if (CorrectionRight > 0) //idk have to find out what this value is.
{ //idea is correctionright tooooooo big, we know we need to turn back
//by turning left . if too small too negative, turn back by turn right
/*
Serial.println("PID TURN LEFT"); //too close to right.
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
analogWrite(RightMotor, 113);
analogWrite(LeftMotor, 0);
delay(100);
countleft++;
*/
//delay(500);
delay(25);
}
}
//inside this part of pid i should also be checking led 1 for reals though tbh based on how i pid or else make sure when i turn back to normal, I AINT LEANING AGAINST NO WALL. and tryna ram a wall.
//129, 135
///delay(1000);
}
//based on my test runs, 70-80s means im hitting a wall in my room. will need to calibrate what
//the real numbers are in the lab with their lighting and their typo walls. but for testing
//purposes in my room, ill just have it register 70-80s is a wall.
// put your main code here, to run repeatedly:
/*
/This code will turn Motor A clockwise for 2 sec.
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(2000);
//This code will turn Motor A counter-clockwise for 2 sec.
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(2000);
//This code will turn Motor B clockwise for 2 sec.
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(2000);
//This code will turn Motor B counter-clockwise for 2 sec.
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(2000);
//And this code will stop motors
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
*/
//how to turn
//stop
/*
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, LOW);
delay(3000);
//cw 1 turn right
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, LOW);
delay(3000);
//stop
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, LOW);
delay(3000);
//ccw 1
digitalWrite(Right1, LOW);
digitalWrite(Right2, HIGH);
digitalWrite(Left1, LOW);
digitalWrite(Left2, LOW);
delay(3000);
//stop
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, LOW);
delay(3000);
//cw 2
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, HIGH);
digitalWrite(Left2, LOW);
delay(3000);
//stop
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, LOW);
delay(3000);
//ccw 2
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, HIGH);
delay(3000);
//stop
digitalWrite(Right1, LOW);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, LOW);
delay(3000);
*/
/*if(LED2V<=80) //left, turn right
{
analogWrite(LeftMotor, 62);
analogWrite(RightMotor, 62);
Serial.println("APPROACHING WALL from LED 2PLEASE TURN");
digitalWrite(Right1, HIGH);
digitalWrite(Right2, LOW);
digitalWrite(Left1, LOW);
digitalWrite(Left2, HIGH);
//turn right
}
*/
// change direction, goes backwards...
/* digitalWrite(LeftMotor, LOW);
digitalWrite(RightMotor, LOW);
delay(1000);
digitalWrite(LeftMotor, HIGH);
digitalWrite(RightMotor, HIGH);
digitalWrite(Right1, LOW);
digitalWrite(Right2, HIGH);
digitalWrite(Left1, LOW);
digitalWrite(Left2, HIGH);
*/