A group and I are making a joystick controlled jeep for a kid in school who is paralyzed from the neck down and can only move his fingers a bit. To control the front tires we are using a 270 degree servo but we could not find a way to limit how much it rotates while using a joystick so that is does not go off the track.
#include <Servo.h>
Servo servo0;
Servo servo1;
int joyX = 0;
int joyY = 1;
int servoVal;
void setup()
{
servo0.attach(5);
servo1.attach(7);
}
void loop()
{
servoVal = analogRead(joyX);
servoVal = map(servoVal, 0, 1023, 0, 180);
servo0.write(servoVal);
servoVal = analogRead(joyY);
servoVal = map(servoVal, 0, 1023, 70, 180);
servo1.write(servoVal);
delay(25);
}
Help is much appreciated