I am trying to control an esc with the teensy 4.1 board but i am not able to get it to work using the PWM Servo library.
#include <PWMServo.h>
int channel[8];
int PPMin = 23;
#define TH1 2
#define TH2 3
PWMServo throttel1;
PWMServo throttel2;
void setup() {
Serial.begin(9600);
throttel1.attach(TH1);
throttel2.attach(TH2);
}
void loop() {
if(pulseIn(PPMin , HIGH) > 4000)
{
for(int i = 1; i <= channumber; i++)
{
channel[i-1]=pulseIn(PPMin, HIGH);
}
int throttle_input = channel[2];
Serial.print("CH[3]: "); Serial.print(channel[2]);
int throttle1_input = map(throttle_input, 1497 ,519 , 0, 180);
throttel1.write(throttle1_input);
int throttle2_input = map(throttle_input, 1497 ,519 , 0, 180);
throttel1.write(throttle2_input);
}
I have also tried with analogwrite but i had no luck.
Any help is appreciated.
Thanks.
#include <PWMServo.h>
int channel[8];
int PPMin = 23;
#define TH1 2
#define TH2 3
PWMServo throttel1;
PWMServo throttel2;
void setup() {
Serial.begin(9600);
throttel1.attach(TH1);
throttel2.attach(TH2);
}
void loop() {
if(pulseIn(PPMin , HIGH) > 4000)
{
for(int i = 1; i <= channumber; i++)
{
channel[i-1]=pulseIn(PPMin, HIGH);
}
int throttle_input = channel[2];
Serial.print("CH[3]: "); Serial.print(channel[2]);
int throttle1_input = map(throttle_input, 1497 ,519 , 0, 180);
throttel1.write(throttle1_input);
int throttle2_input = map(throttle_input, 1497 ,519 , 0, 180);
throttel1.write(throttle2_input);
}
I have also tried with analogwrite but i had no luck.
Any help is appreciated.
Thanks.