Reference
This is the list of every name a MicroPython program can use on a MoBot, for firmware 3.0. It covers the three kits. The Smart Car and the Mini are reached through robot. The Smart Home is reached through home.
Choose your kit
Section titled “Choose your kit”| Kit | Your program uses | Start here |
|---|---|---|
| Smart Car | robot |
robot on the Smart Car |
| Mini | robot |
robot on the Mini |
| Smart Home | home |
home on the Smart Home |
Smart Car
Section titled “Smart Car”The MoBot Smart Car: every part of the robot is reached through this object, robot. Start with robot. These are its classes:
BLEController: The robot’s Bluetooth link to the MoBot app on your phone.Gamepad: The Game Pad in the MoBot app on your phone, received over Bluetooth.Led: One of the robot’s lights (led1 or led2); brightness is in percent, 0 to 100.Buzzer: The robot’s buzzer: it plays songs in the background while your program goes on.Motor: One drive motor of the robot (left_motor or right_motor); speeds are in percent.Servo: A servo motor on one of the robot’s servo plugs; angles are in degrees, 0 to 180.LineSensor: Sees a dark line on a light floor.DistanceSensor: Measures how far away something is.ColorSensor: Measures how much red, green and blue light comes back from a surface.Compass: Tells which way the robot is facing, in degrees.Battery: Measures the battery’s voltage, which drops as the battery empties.Joystick: Reads how far the stick is pushed, left to right (x()) and forward to back (y()).
The MoBot Mini: every part of the robot is reached through this object, robot. Start with robot. These are its classes:
BLEController: The robot’s Bluetooth link to the MoBot app on your phone.Gamepad: The Game Pad in the MoBot app on your phone, received over Bluetooth.Led: One of the robot’s lights (led1 or led2); brightness is in percent, 0 to 100.Buzzer: The robot’s buzzer: it plays songs in the background while your program goes on.DRV8833Motor: One drive motor of the robot (left_motor or right_motor); speeds are in percent.RGBLed: The robot’s colour light; colours are red, green and blue from 0 to 255, brightness in percent.LineSensor: Sees a dark line on a light floor.DistanceSensor: Measures how far away something is.
Smart Home
Section titled “Smart Home”The MoBot Smart Home: every part of the house is reached through this object, home. Start with home. These are its classes:
TemperatureSensor: Measures the temperature in degrees Celsius and how much water vapour is in the air (humidity, in percent).MotionSensor: Notices a person or an animal moving nearby.GasSensor: Notices gases and smoke in the air.LightSensor: Measures how bright it is: a special resistor lets more electricity through when more light falls on it.Knob: Reads how far the knob is turned.Button: The house’s push button.Battery: Measures the battery’s voltage, which drops as the battery empties.RFIDReader: Reads the number of a card or tag held close to it.Display: The house’s screen: 128 x 64 dots, x from 0 (left) to 127, y from 0 (top) to 63.RGBLed: The house’s colour lamp; colours are red, green and blue from 0 to 255.NumberDisplay: The house’s three-digit number display.Buzzer: The house’s buzzer; frequencies are in hertz and durations in milliseconds.Servo: The house’s servo motor (the door); angles are in degrees, 0 to 180.Fan: The house’s fan; its speed is in percent, 0 to 100.Wifi: The house’s Wi-Fi: its address, its name and the networks it remembers.Dashboard: The house’s web page: the readings, and the switches, sliders and boxes a program adds.
How to read a reference page
Section titled “How to read a reference page”- The title of a page is a class, such as
Motor. A class is a kind of part. The first page of a kit is the object itself:robotorhome. - How you reach it lists the attributes that give you that class. On the Smart Car,
robot.left_motorandrobot.right_motorare both a Motor. - Each heading is a call.
forward(speed)means you write the name and give it a value forspeed. You put the object in front of it, for examplerobot.left_motor.forward(60). - Used in examples under a call links to the Python examples that use it.
- Some attributes can be
None. The page ofrobotorhomeexplains when. - Old names. Programs written for firmware 2.x use other names. Names from 2.x to 3.0 lists every change.
- Where the names come from. The names and sentences on these pages are the firmware’s own, the same ones the MoBot IDE uses for autocomplete when you type a program.
How to read a signature
Section titled “How to read a signature”Under each heading, a code block shows the call:
| You see | It means |
|---|---|
speed: int |
The type comes after the colon. int is a whole number, float a number with a decimal point, str text, bool True or False. No type: any value will do. |
index=None |
The value is optional. Leave it out and it is None. |
You can leave out speed. |
A sentence like this under a call names a value that is optional. Leave it out and the call still works. A value that is not named there, and has no =None, has to be given. |
-> bool |
What the call gives back. With no arrow, nothing useful comes back, or the sentence above the code says what it is. |
List[str] |
A list of text values. Dict[str, bool] is a dict from text to True or False. Tuple[int, int, int] is a fixed group of three whole numbers. Optional[int] is an int or None. |