#define FREQ 250 // Sampling frequency
// ----------------------- Variables for servo signal generation -------------
unsigned int period; // Sampling period
unsigned long add = 10,loop_timer;
unsigned long now, difference;
unsigned long pulse_length_esc1 = 1000,
pulse_length_esc2 = 1000,
pulse_length_esc3 = 1000,
pulse_length_esc4 = 1000;
void setup() {
// put your setup code here, to run once:
// Set pins #4 #5 #6 #7 as outputs
DDRD |= B11110000;
period = (1000000/FREQ) ; // Sampling period in µs
applyMotorSpeed();
// Initialize loop_timer
loop_timer = micros();
// Turn LED off now setup is done
digitalWrite(13, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
pulse_length_esc1 = 1000;
digitalWrite(13, HIGH);
applyMotorSpeed();
delay(500);
pulse_length_esc1 = 4000;
digitalWrite(13, LOW);
applyMotorSpeed();
delay(500);
}