This repository was archived by the owner on Oct 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,6 @@ int enb = 3;
8
8
int in2 = 5 ;
9
9
int in1 = 7 ;
10
10
11
- // MOTOR RIGHT NEGATIVE = 2
12
- // MOTOR RIGHT POSITIVE = 4
13
-
14
- // MOTOR LEFT NEGATIVE = 5
15
- // MOTOR LEFT POSITIVE = 7
16
-
17
11
void setup () {
18
12
// Set the motor control pins as output
19
13
pinMode (in1, OUTPUT);
@@ -26,11 +20,13 @@ void setup() {
26
20
// Start the serial connection at 9600 Bauds
27
21
Serial.begin (9600 );
28
22
23
+ // set the speed control (255 Max) for the motors
29
24
analogWrite (ena, 255 ); // LEFT
30
- analogWrite (enb, 180 ); // RIGHT
25
+ analogWrite (enb, 180 ); // RIGHT (-75 power)
31
26
}
32
27
33
28
void loop () {
29
+ // Our debug code to prove that the bot is running
34
30
moveForward ();
35
31
delay (6000 );
36
32
moveBackward ();
@@ -42,34 +38,39 @@ void loop() {
42
38
stopMoving ();
43
39
}
44
40
41
+ // Bot moves forward
45
42
void moveForward () {
46
43
digitalWrite (in1, HIGH);
47
44
digitalWrite (in2, LOW);
48
45
digitalWrite (in3, HIGH);
49
46
digitalWrite (in4, LOW);
50
47
}
51
48
49
+ // Bot moves backwards
52
50
void moveBackward () {
53
51
digitalWrite (in1, LOW);
54
52
digitalWrite (in2, HIGH);
55
53
digitalWrite (in3, LOW);
56
54
digitalWrite (in4, HIGH);
57
55
}
58
56
57
+ // Bot turns left
59
58
void moveLeft () {
60
59
digitalWrite (in1, LOW);
61
60
digitalWrite (in2, HIGH);
62
61
digitalWrite (in3, HIGH);
63
62
digitalWrite (in4, LOW);
64
63
}
65
64
65
+ // Bot turns right
66
66
void moveRight () {
67
67
digitalWrite (in1, HIGH);
68
68
digitalWrite (in2, LOW);
69
69
digitalWrite (in3, LOW);
70
70
digitalWrite (in4, HIGH);
71
71
}
72
72
73
+ // Bot stops moving
73
74
void stopMoving () {
74
75
digitalWrite (in1, LOW);
75
76
digitalWrite (in2, LOW);
You can’t perform that action at this time.
0 commit comments