Last active
May 7, 2018 00:08
-
-
Save liz-miller/80d26ad9046c8bddb17e5d5974a4d36b to your computer and use it in GitHub Desktop.
How to make an Arduino Robot | Move Step #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Move Method (Step #2) | |
* Controls how our robot moves. | |
* Developed for the Beginner Bots lesson series on www.learnrobotics.org/blog | |
* Written by Liz Miller | |
* 5/6/2018 | |
*/ | |
/** Global Variables **/ | |
//Left Motor | |
int enableA = 10; | |
int motorA1 = 9; | |
int motorA2 = 8; | |
//Right Motor | |
int enableB = 5; | |
int motorB3 = 7; | |
int motorB4 = 6; | |
//move two motors for a set duration and speed | |
void move(int motor1, int motor2, int enable, int speed, int duration){ | |
// code goes here | |
// -- NEW CODE STARTS HERE -- | |
// 1. turn on motor | |
digitalWrite(motor1, HIGH); | |
digitalWrite(motor2, LOW); | |
// 2. set speed (to 200 out of possible range 0~255) | |
analogWrite(enable, speed); | |
// 3. run for specified time | |
delay(duration); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment