pxt-calliope/docs/examples/servo-calibrator.md
Peli de Halleux 676eee168a Soil - moisture ()
* updated servo calibrator

* updated plot analog pin example

* updated servo example

* first drop of soil moisture

* updated picture

* fixing macros

* update code section

* 5 seconds

* adding soil moisture

* fixing links
2017-06-21 11:17:25 -07:00

605 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, 5)
    pins.servoWritePin(AnalogPin.P0, angle)
    led.stopAnimation()
})
input.onButtonPressed(Button.B, () => {
    angle += Math.min(180, 5)
    pins.servoWritePin(AnalogPin.P0, angle)
    led.stopAnimation()
})
basic.forever(() => {
    basic.showNumber(angle)    
})
pins.servoWritePin(AnalogPin.P0, angle)