Skip to content

Instantly share code, notes, and snippets.

@ricklon
Created July 2, 2017 21:04
Show Gist options
  • Save ricklon/37548f8492ee554d6f8e16dae2dd849b to your computer and use it in GitHub Desktop.
Save ricklon/37548f8492ee554d6f8e16dae2dd849b to your computer and use it in GitHub Desktop.
//Test Routine Program - By Stezipoo
#include <Servo.h>
//create servo objects
Servo steering;
Servo throttle;
int ledPin = 13;
int center = 95;
int right = 55;
int left = 130;
void setup()
{
Serial.begin(9600);
delay(250);
pinMode(A1, INPUT);
pinMode(16, INPUT);
pinMode(7, OUTPUT); //sets pin 9 to output
pinMode(10, OUTPUT);
steering.attach(7); // attach steering servo to pin 9
throttle.attach(10); // attach ESC to pin 10
steering.write(95); // centers steering
throttle.write(90); // sets mid throttle
}
void loop()
{
unsigned long STR_VAL = pulseIn(A1, HIGH, 25000); // Read the pulse width of
unsigned long THR_VAL = pulseIn(16, HIGH, 25000); // each channel
// Serial.printf("%d, %d,", STR_VAL, THR_VAL);
// for (int ii = 1000; ii <2000; ii++)
//STR_VAL = map(STR_VAL, 1000, 2000, 145, 35 );
//THR_VAL = map(THR_VAL, 1000, 2000, 90, 135);
steering.writeMicroseconds(STR_VAL);
throttle.writeMicroseconds(THR_VAL);
delay(10);
// Serial.printf("%d, %d\n", STR_VAL, THR_VAL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment