Power Board API¶
The power board can be accessed using the
power_board property of
my_power_board = robot.power_board
The six outputs of the power board are grouped together as
The power board's six outputs can be turned on and off using the
power_off functions of the group respectively.
power_on is called when you set up your robot, so
this doesn't need to be called manually. The ports will come on
automatically as soon as your robot is ready, before the start button is
You can also get information about and control each output in the group.
An output is indexed using the appropriate
from sbot import PowerOutputPosition robot.power_board.outputs[PowerOutputPosition.H0].is_enabled = True robot.power_board.outputs[PowerOutputPosition.L3].is_enabled = False boolean_value = robot.power_board.outputs[PowerOutputPosition.L2].is_enabled current_amps = robot.power_board.outputs[PowerOutputPosition.H1].current
The motor and servo boards are powered through these power outputs, whilst the power is off, you won't be able to control your motors or servos. They will register as a missing board and your code will break if you try and control them.
The power board has some sensors that can monitor the status of your battery. This can be useful for checking the charge status of your battery.
battery_voltage = robot.power_board.battery_sensor.voltage battery_current_amps = robot.power_board.battery_sensor.current
The power board has a piezo sounder which can buzz.
buzz function accepts two parameters. The first argument is the duration of the beep, in seconds.
The second argument is either the note you want to play, or the frequency of the buzzer (in Hertz).
Theoretically, the piezo buzzer will buzz at any provided frequency, however humans can only hear between 20Hz and 20000Hz.
Note enum provides notes in scientific pitch notation between
C8. You can play other tones by providing a frequency.
buzz is non-blocking, which means it doesn't
actually wait for the piezo to stop buzzing before continuing with your
code. If you want to wait for the buzzing to stop, add a
sleep afterwards! If you send more than 32 beeps to the robot too
quickly, your power board will crash!
from sbot import Note # Buzz in D6 for half a second robot.power_board.piezo.buzz(Note.D6, 0.5) # Buzz at 400Hz for 2 seconds robot.power_board.piezo.buzz(400, 2)
You can manually wait for the start button to be pressed, not only at the start.
This may be useful for debugging, but be sure to remove it in the competition, as you won't be allowed to touch the start button after a match has begun!