I have a BLDC motor with an ESC,, I'm controlling it with a joystick connected to an Arduino This code works fine except the joystick is too sensitive, just the slightest touch will start the motor and it's hard to get it to stop when the joystick is in the center position. The off zone needs to be expanded so that the motor won't run until the joystick is pushed harder. I've tried other joysticks and they do the same thing. I've tried changing the min/max values but can't seem to find what makes the off zone larger. Any suggestions?
Code:
#include <Servo.h> //Using servo library to control ESC
Servo esc; //Creating a servo class with name as esc
void setup()
{
esc.attach(10); //Specify the esc signal pin,Here as D10
esc.writeMicroseconds(1000); //initialize the signal to 1000
Serial.begin(9600);
}
void loop()
{
int val; //Creating a variable val
val= analogRead(A0); //Read input from analog pin a0 and store in val
val= map(val, 0, 1023,1000,2000); //mapping val to minimum and maximum(Change if needed)
esc.writeMicroseconds(val); //using val as the signal to esc
}