Skip to content

Instantly share code, notes, and snippets.

@kvablack
Created May 25, 2017 16:05
Show Gist options
  • Save kvablack/cea3f95046acae10cc2ee15abafb16ef to your computer and use it in GitHub Desktop.
Save kvablack/cea3f95046acae10cc2ee15abafb16ef to your computer and use it in GitHub Desktop.
#include <Servo.h>
#define distance 9.42038797 //in meters, determines time
#define MotorPort 9
#define FORWARD 101 //speed
#define COAST 90
#define extraTime 1 //in seconds so the car drives longer than necessary
//#define driveTime 4000
Servo motor;
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
motor.attach(9);
motor.write(FORWARD);
delay((.2753 * distance + .3308 + extraTime)*1000);
motor.write(COAST);
motor.detach();
}
void loop() {
// put your main code here, to run repeatedly:
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment