From f27e575974d512c97be49b362a10d3e213a368a3 Mon Sep 17 00:00:00 2001 From: Denis Zheleztsov Date: Wed, 21 Nov 2018 12:29:53 +0300 Subject: [PATCH] Fix Go for :) --- simple.ino => car.ino | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) rename simple.ino => car.ino (78%) diff --git a/simple.ino b/car.ino similarity index 78% rename from simple.ino rename to car.ino index 8216611..92fd2b0 100644 --- a/simple.ino +++ b/car.ino @@ -1,15 +1,18 @@ /* Define you pins here */ -const int left_wheel_1 = 0; -const int left_wheel_2 = 1; +const int left_wheel_1 = 0; +const int left_wheel_2 = 1; const int right_wheel_1 = 2; const int right_wheel_2 = 3; +/* The counter */ +int i; + /* Array bellow contains all the wheels */ int Wheels[] = {left_wheel_1, left_wheel_2, right_wheel_1, right_wheel_2}; void setup() { /* Setup pins */ - for i = 0; i < sizeof(Wheels) - 1; i++ { + for (i = 0; i < sizeof(Wheels) - 1; i++) { pinMode(Wheels[i], OUTPUT); } } @@ -50,7 +53,7 @@ void move_backward() { /* Stops */ void stop_all() { - for i := 0; sizeof(Wheels) - 1; i++ { + for (i = 0; sizeof(Wheels) - 1; i++) { digitalWrite(Wheels[i], LOW); } } @@ -65,6 +68,7 @@ void stop_right() { digitalWrite(right_wheel_2, LOW); } +/* Turns */ void turn_left(int delayMS) { stop_left(); move_forward_wheel_right(); @@ -79,5 +83,16 @@ void turn_right(int delayMS) { /* Main code */ 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); }