Benchmark icon Benchmark — Diagnose EZ-B connection speed and reliability; benchmark ADC read rates (4-70/sec), reveal flood-control effects and optimize data throttle. Try it →
Robot Showcase

Counting Rotations Of A Parallax Feedback 360 Degree Servo

2,493 views 0 comments

About this robot

I thought this script might be useful for someone wanting to specify the number of rotations for a Parallax Feedback 360 degree servo. The servo is connected to port D0 and the 4th wire to ADC0.

#Rotate anti-clockwise for 5 rotations Servo(D0,80) $rotations = 0 $ADC = 999 $PreviousADC = 999 repeatwhile($rotations < 6) $ADC = GetADC(adc0) #Determine if value of ADC has increased significantly - If so, one rotation has occurred if ($ADC > $PreviousADC + 100) $rotations = $rotations + 1 endif print("Previous ADC " + $PreviousADC + " - Current ADC " + $ADC + " - Rotations: " + $rotations) $PreviousADC = $ADC sleep(10) endrepeatwhile Servo(D0,105) sleep(1000)

#Rotate clockwise for 5 rotations Servo(D0,130) $rotations = 0 $ADC = -1 $PreviousADC = -1 repeatwhile($rotations < 6) $ADC = GetADC(adc0) #Determine if value of ADC has decreased significantly - If so, one rotation has occurred if ($ADC < $PreviousADC - 100) $rotations = $rotations + 1 endif

print("Previous ADC " + $PreviousADC + " - Current ADC " + $ADC)

$PreviousADC = $ADC sleep(10) endrepeatwhile #ADC_Wait_Between(adc0,0,4,5) Servo(D0,105) sleep(1000)

By

Discover more robots

Robots the community built with Synthiam ARC. Get ideas for your next build.


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.