#include <Servo.h>
Servo m1;
int ch1;
void setup() {
m1.attach(5);
Serial.begin(115200);
}
void loop()
{
getValues();
comanda_THROTTLE = to100(ch1); //to100 is a function so I can see a percentage of the command I send
Serial.print("Throttle: "); Serialprintln(comanda_THROTTLE);
m1.write(toMotor(comanda_THROTTLE)); //toMotor is the command, scaled in the motor range (50-125)
}
void getValues()
{
ch1 = pulseIn(A0,HIGH,25000);
}
int to100(int a)
{
return map(a, 1056, 1885, 0, 100);
}
int toMotor(int a)
{
return map(a, 0, 100, 50, 125);
}
If I use the noInterrupt in my getValues() function, then I can read the values perfectly, but my servo won't work anymore.
Is there a way to use pulseIn with another timer than the one used by the interrupts?
