Approved content
The content below is provided by a partner.
More info for Roversa can be found on roversa.com or on the Roversa page at GlobalCSED.
Pins are matched to the following micro:bit inputs:
P8
= Menu
P5
= Play
P9
= Pause
P13
= Forward
P14
= Reverse
P15
= Right
P16
= Left
Roversa button isPressed
allows users to select any of the 7 buttons mapped to the micro:bit on Roversa. Buttons include FWD, REV, LEFT, RIGHT, STOP, MENU, PLAY. Users can make these buttons do anything in Blocks and Javascript
roversa.isPressed(RoversaPin.P5)
Determines if a button is pressed
Roversa button onEvent
allows users to select any of the above buttons and create an event on the button down, up, or click. In the above example when you push the Menu button on Pin 5 the LED display the string “Hello”.
roversa.onEvent(RoversaPin.P5, RoversaEvent.Down, function() {
basic.showString("Hello!")
})
Registers code to run when a Roversa event is detected.
Users can use bias to ensure that the servos are moving in a similar fashion. This will allow users to change the left or right motor regardless of trim. 0-50 adjust the left motor, 50-100 adjusts the right motor.
roversa.biasDriving(50)
Apply a bias to the wheels. 0 to 50 for left, 50 to 100 for right.
Users can also adjust the amount of degrees per turn and amount of mm per second when using future function like turning a certain number of degrees or moving a specified distance. This ensures that Roversa is moving exactly as planned. Use these to coincide with roversa.turnLeft
and roversa.turnRight
for turning and roversa.driveForwards
and roversa.driveBackwards
to go a straight distance. In this example it will turn 2 degrees/s or move 10 mm/s.
roversa.setDegreesPerSecond(2)
Allows the setting of Roversa turn amount. This allows tuning for the turn x degrees commands
roversa.setDistancePerSecond(10)
Allows the setting of Roversa forward / reverse distance. This allows tuning for the move x distance commands
Users can drive forward, backward, left and right turns which will only stop by calling the stop. Stop actually stops analog signal to ensure the robot fully stops regardless of bias. The nuetral position should pause the motors and keep them stationary and will depend on how your motors are trimmed.
roversa.forward()
Drives forwards. Call stop to stop
roversa.backward()
Drives backwards. Call stop to stop
roversa.right()
Turns right. Call stop to stop
roversa.left()
Turns left. Call stop to stop
Users can also select specific distances to drive the robot forward and backwards. This is also similar to selecting specific angles for turning. Be sure to use the calibration before using these last 4 functions to make sure your robot is going the correct distances and angles. In this example it is driving 10 mm or turning 90 degrees.
roversa.driveForwards(10)
Drives forwards the requested distance and then stops
roversa.driveBackwards(10)
Drives backwards the requested distance and then stops
roversa.turnRight(90)
Turns right through the requested degrees and then stops, needs NumberOfDegreesPerSec tuned to make accurate, as it uses a simple turn, wait, stop method. Runs the servos at slower than the left function to reduce wheel slip
roversa.turnLeft(90)
Turns left through the requested degrees and then stops, needs NumberOfDegreesPerSec tuned to make accurate, as it uses a simple turn, wait, stop method. Runs the servos at slower than the right function to reduce wheel slip
MIT
roversa=github:eb8ga/pxt-roversa-2#v1.0.27