pxt-calliope/docs/projects/light-monster/connect.md
2017-12-05 15:59:36 -08:00

27 lines
618 B
Markdown

# Connect
## ~avatar avatar
Remote control your monster with another @boardname@
## ~
## Duration: ~30 minutes
In order for the light monster to move, the @boardname@ needs to command the servo to move between ``0`` and ``180`` degrees at a certain pace. The code below starts the inchworm moving when the **A** button is pressed.
```blocks
radio.onDataPacketReceived(({receivedNumber}) => {
pins.servoWritePin(AnalogPin.P0, 30)
basic.pause(500)
pins.servoWritePin(AnalogPin.P0, 150)
basic.pause(500)
})
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
```
```package
radio
```