pxt-calliope/docs/projects/servo-calibrator.md
Peli de Halleux d0a40d1ae1
tools lessons ()
* tools lessons

* updated summary

* more images

* wire up images

* fixing radio send-value
2018-09-12 13:26:39 -07:00

619 B

Servo calibrator

Use this program to calibrate the angles of a servo. Press A to reduce the angle by 5 and B to increase it by 5.

The current angle is displayed on the screen in a loop.

let angle = 90
input.onButtonPressed(Button.A, () => {
    angle = Math.max(0, angle - 5)
    pins.servoWritePin(AnalogPin.P0, angle)
    led.stopAnimation()
})
input.onButtonPressed(Button.B, () => {
    angle = Math.min(180, angle + 5)
    pins.servoWritePin(AnalogPin.P0, angle)
    led.stopAnimation()
})
basic.forever(() => {
    basic.showNumber(angle)    
})
pins.servoWritePin(AnalogPin.P0, angle)