I am attempting to get a 4-in-1 sensor to work as I need it to and not have much success - I need a hand.
I am trying to get the 4- in-1 sensor to drive 2 servos to keep something level/plumb.
I have the servos set to go up or down depending on the sensor readings. The problems I'm having are;
1. It will kind of work for a short time but will only drive one servo at a time even if both should move,
2. The Y axis stops working after a few minutes,
3. Then everything stops working,
4. For some reason the 'Sleep' command above the 'loop' is run each time and anything else put there -except the first line.
I am running the sensor on a EZBv4/2. My code is a modified version of one from a JD project.
Here's my code;
#Added these because $AccelX and $AccelY were not recognized later in the script for some reason.
$XAccel = $AccelX
$YAccel = $AccelY
if ("x" =0)
print("x: " + $XAccel)
print("y: " + $YAccel)
if ($XAccel > 1000)
ELSEif ($XAccel < -1000)
if ($YAccel > 1000)
ELSEif ($YAccel < -1000)
Has anyone played with these sensors much and got them working? I know I have a lot to learn about them so your assistance will be appreciated.