Skip to content

Instantly share code, notes, and snippets.

@lazychino
Last active August 29, 2015 14:01
Show Gist options
  • Save lazychino/01528ccfd4b61a211ab9 to your computer and use it in GitHub Desktop.
Save lazychino/01528ccfd4b61a211ab9 to your computer and use it in GitHub Desktop.
/*
* Run Bot! Run! by Pedro A. Melendez
*
* Test robot motor function and helps for calibration,
* so that our bot run in a straight line
*
*/
const int proximitySensor = A0; // Analog input pin that the potentiometer is attached to
const int ledPin = 13; // integrated LED on the Arduino Leonardo
const int rightForward = 5;
const int rightReverse = 4;
const int rightSpeedPin = 3; //pwm
const int leftForward = 11;
const int leftReverse = 10;
const int leftSpeedPin = 9; //pwm
// speed value for direction calibration
const int rightSpeed = 255;
const int leftSpeed = 255;
void stopBot()
{
digitalWrite(rightForward, LOW);
digitalWrite(rightReverse, LOW);
digitalWrite(leftForward, LOW);
digitalWrite(leftReverse, LOW);
analogWrite(rightSpeedPin, 0);
analogWrite(leftSpeedPin, 0);
}
void runBot(){
digitalWrite(rightForward, HIGH);
digitalWrite(rightReverse, LOW);
digitalWrite(leftForward, HIGH);
digitalWrite(leftReverse, LOW);
analogWrite(rightSpeedPin, rightSpeed);
analogWrite(leftSpeedPin, leftSpeed);
}
void setup() {
Serial.begin(9600);
pinMode(rightForward, OUTPUT);
pinMode(rightReverse, OUTPUT);
pinMode(leftForward, OUTPUT);
pinMode(leftReverse, OUTPUT);
stopBot(); // initializes pins
runBot();
delay(10000);
stopBot();
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment