Fix Go for :)
This commit is contained in:
parent
62996c9327
commit
f27e575974
@ -4,12 +4,15 @@ const int left_wheel_2 = 1;
|
|||||||
const int right_wheel_1 = 2;
|
const int right_wheel_1 = 2;
|
||||||
const int right_wheel_2 = 3;
|
const int right_wheel_2 = 3;
|
||||||
|
|
||||||
|
/* The counter */
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Array bellow contains all the wheels */
|
/* Array bellow contains all the wheels */
|
||||||
int Wheels[] = {left_wheel_1, left_wheel_2, right_wheel_1, right_wheel_2};
|
int Wheels[] = {left_wheel_1, left_wheel_2, right_wheel_1, right_wheel_2};
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
/* Setup pins */
|
/* Setup pins */
|
||||||
for i = 0; i < sizeof(Wheels) - 1; i++ {
|
for (i = 0; i < sizeof(Wheels) - 1; i++) {
|
||||||
pinMode(Wheels[i], OUTPUT);
|
pinMode(Wheels[i], OUTPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +53,7 @@ void move_backward() {
|
|||||||
|
|
||||||
/* Stops */
|
/* Stops */
|
||||||
void stop_all() {
|
void stop_all() {
|
||||||
for i := 0; sizeof(Wheels) - 1; i++ {
|
for (i = 0; sizeof(Wheels) - 1; i++) {
|
||||||
digitalWrite(Wheels[i], LOW);
|
digitalWrite(Wheels[i], LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,6 +68,7 @@ void stop_right() {
|
|||||||
digitalWrite(right_wheel_2, LOW);
|
digitalWrite(right_wheel_2, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Turns */
|
||||||
void turn_left(int delayMS) {
|
void turn_left(int delayMS) {
|
||||||
stop_left();
|
stop_left();
|
||||||
move_forward_wheel_right();
|
move_forward_wheel_right();
|
||||||
@ -79,5 +83,16 @@ void turn_right(int delayMS) {
|
|||||||
|
|
||||||
/* Main code */
|
/* Main code */
|
||||||
void loop() {
|
void loop() {
|
||||||
|
move_forward();
|
||||||
|
delay(1000);
|
||||||
|
turn_left(500);
|
||||||
|
move_backward();
|
||||||
|
delay(1000);
|
||||||
|
turn_right(500);
|
||||||
|
move_forward();
|
||||||
|
turn_left(500);
|
||||||
|
turn_left(500);
|
||||||
|
turn_left(500);
|
||||||
|
move_forward();
|
||||||
|
delay(1000);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user