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 interpreter that runs on small embedded development boards.
rero:micro has 3 built-in infrared sensor connected to micro:bit's P13, P14, P15 to line follow.
This is the fifth lesson (LineFollow) 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 | 3 Move Around
- Program micro:bit mobile robot with Python | 4 Detect Object
Check out the first lesson (Colour Splash) for the guidelines to setup the software.
LINE FOLLOWCODING
To program the rero:micro you need to add these code:
from reromicro import *
rero = reromicro()
rero.ReadLineSensors()
function must be called to read all three line sensors first before using
Use rero.LineIrIntensity(rero.(x))
to get the reflected infrared (IR) intensity value, ranging from 0 to 1500
from reromicro import *
rero = reromicro()
while True:
rero.ReadLineSensors()
display.scroll(rero.LineIrIntensity(rero.centerSensor))
sleep(500)
rero.LineSensorDetectsLine(rero.(x))
returns true if the value is more than the threshold value
Here is an example code to line follow
from reromicro import *
rero = reromicro()
while True:
rero.ReadLineSensors()
if rero.LineSensorDetectsLine(rero.centerSensor):
rero.RunMotor(50, 50)
elif rero.LineSensorDetectsLine(rero.rightSensor):
rero.RunMotor(40, -40)
elif rero.LineSensorDetectsLine(rero.leftSensor):
rero.RunMotor(-40, 40)
UPLOAD
MU EDITOR
Check out the first lesson (Colour Splash) for the guidelines to upload program to rero:micro
Comments
Please log in or sign up to comment.