This is the MakeCode Package for the OC05 xChip.
- Open Microsoft MakeCode for micro:bit.
- Select Advanced > Add Package in the toolbox.
- Copy and paste https://github.com/xinabox/pxt-OC05 in the search bar and click search
- Select the package by clicking on it. The package will appear along with the existing packages in the toolbox.
setServoPosition(servoChannel: number, degrees: number)
Positions a servo on the selected channel a desired degree of rotation.
- servoChannel: the channel number on the OC05 (1 - 8)
- degrees: desired degree of rotation
setCRServoPosition(servoChannel: number, speed: number)
Rotates a servo on the selected channel with desired percent of speed
- servoChannel: the channel number on the OC05 (1 - 8)
- speed: percent of speed to rotate (-100% - 100%)
setServoLimits(servoChannel: number, minimum: number, maximum: number)
Bound servo motor movement within maximum and minimum degrees entered
- servoChannel: the channel number on the OC05 (1 - 8)
- minimum: lower limit of servo movement in degrees
- maximum: upper limit of servo movement in degrees
input.onButtonPressed(Button.A, () => {
OC05.setServoPosition(OC05.ServoNum.Servo1, 0)
basic.showString("A")
})
input.onButtonPressed(Button.B, () => {
OC05.setServoPosition(OC05.ServoNum.Servo1, 180)
basic.showString("B")
})
input.onButtonPressed(Button.AB, () => {
OC05.setServoPosition(OC05.ServoNum.Servo1, 90)
basic.showString("C")
})
MIT
- for PXT/microbit
OC05=github:xinabox/pxt-OC05