pybot is the MicroPython library installed on every PyBot Beaver Board (ESP32). Import it once and use the objects directly: import pybot.
Speed is 0–100. Reversing direction coasts for 60 ms first to protect the gears.
| Call | What it does |
|---|
pybot.motor.forward(speed=50) | Drive both motors forward. |
pybot.motor.backward(speed=50) | Drive both motors backward. |
pybot.motor.left(speed=50) | Turn left. |
pybot.motor.right(speed=50) | Turn right. |
pybot.motor.stop() | Stop both motors. |
import pybot, time
pybot.motor.forward(60)
time.sleep(2)
pybot.motor.stop()
n is "RED", "YEL", "GRN" or 1–3.
| Call | What it does |
|---|
pybot.led.on(n="RED") | Turn an LED on. |
pybot.led.off(n="RED") | Turn an LED off. |
pybot.led.toggle(n="RED") | Flip an LED. |
pybot.led.brightness(n, value) | Dim an LED, value 0–100. |
| Call | What it does |
|---|
pybot.display.show(text, line=0) | Write text on a line (0–7). |
pybot.display.clear() | Clear the screen. |
| Call | What it does |
|---|
pybot.button.is_pressed("A") | True while the button is held. Use "A", "B" or "C". |
pybot.button.wait("A") | Block until the button is pressed. |
| Call | What it does |
|---|
pybot.buzzer.beep(duration=0.5, freq=2700) | Play a tone. |
pybot.buzzer.off() | Silence the buzzer. |
| Call | Returns |
|---|
pybot.temperature() | Temperature in °C (SHT40). |
pybot.humidity() | Relative humidity in % (SHT40). |
pybot.light() | Ambient light, 0–100. |
pybot.distance() | Distance in cm from the optional VL53L4CD sensor, or 400 when nothing is detected. |
pybot.line_left() / pybot.line_right() | True when the sensor sees a dark line. |
pybot.battery_voltage() | Battery voltage in volts. |
import pybot, time
while True:
pybot.display.clear()
pybot.display.show("Temp: %.1f C" % pybot.temperature(), 0)
pybot.display.show("Light: %d" % pybot.light(), 1)
time.sleep(1)
import pybot
while True:
left = pybot.line_left()
right = pybot.line_right()
if left and not right:
pybot.motor.left(40)
elif right and not left:
pybot.motor.right(40)
else:
pybot.motor.forward(50)
| Call | What it does |
|---|
pybot.cloud.sync(device_key) | Connect to PyBot cloud variables. |
pybot.cloud.get_bool(name, default) / get_number / get_text | Read a cloud variable. |
pybot.remote.command() | Returns "forward", "backward", "left", "right" or "stop" from the remote joystick. |
For raw GPIO numbers see the Beaver Board pinout.