rero:micro is a child-friendly robot kit using micro:bit that is specially designed to encourage young children to learn coding in a fun and easy manner.
MicroPython is an open source Python programming language interpretor that runs on small embedded development boards.
rero:micro has 2 DC motor with wheels connected to micro:bit's P8 and P16 to drive the robot.
This is the third lesson (MoveAround) for this series. Check out the other lessons in the links below:
- Program micro:bit mobile robot with Python | 1 Colour Splash
- Program micro:bit mobile robot with Python | 2 Play Music
- Program micro:bit mobile robot with Python | 4 Detect Object
- Program micro:bit mobile robot with Python | 5 Line Follow
Check out the first lesson (Colour Splash) for the guidelines to setup the software.
MOVE AROUNDCODING
To program the rero:micro you need to add these code:
from reromicro import *
rero = reromicro()
Micro:bit's 5x5 LED display can be used to find the light level of our surrounding.
rero.RunMotor()
takes two arguments. First argument is the speed and direction for the left motor, second argument is the speed and direction for the right motor. Negative value for the motor to move backward, positive value to move forward. Greater value indicates higher speed. 0 for brake.
display.read_light_level()
returns an integer between 0 and 255 representing the light level, with larger value meaning more light.
Here is an example program to moving rero:micro:
from reromicro import *
rero = reromicro()
while True:
if button_a.was_pressed():
rero.Brake() # brake
sleep(2000) # delay 2 second
else :
if display.read_light_level() > 60:
rero.RunMotor(-50, 50) # turn left
sleep(100)
else :
rero.RunMotor(50, 50) # move forward
rero:micro brakes for 2 seconds if button A is pressed
rero:micro will turn left in the speed of 50 if the light level is more than 60, else it will move forward in the speed of 50
UPLOAD
Check out the first lesson (Colour Splash) for the guidelines to upload program to rero:micro
LINK FOR THE NEXT LESSON - Program micro:bit mobile robot with Python | 4 Detect Object
Comments
Please log in or sign up to comment.