EDU:BIT is a beginner-friendly micro:bit kit specially designed to encourage kids to explore STEAM and learn coding.
MicroPython is an open source Python programming language interpreter that runs on small embedded development boards.
This project uses the traffic light bit and a servo motor included in the kit.
SOFTWARE SETUPMU EDITOR
Step 1: Download and install MU editor
Download MU editor at: https://codewith.mu/en/download
Click on the downloaded file to install MU editor
Step 2: Add module
Download MicroPython module from GitHub: https://github.com/Bhavithiran97/micropython-edubit
Copy edubit.py file and paste it in your computer's mu_code folder
- On Windows, the path is: C:\Users<username>\mu_code
- On Macintosh, the path is: Macintosh HD>Users>username>mu_code
Connect EDU:BIT to your computer using a USB cable and open MU editor.
Click in the Files button in the MU editor
A file panel will appear in the bottom of the editor
Drag and drop edubit.py from the right panel to left panel
Python editor for micro:bit
Step 1: Open Python Editor
Open Python editor at: https://python.microbit.org/v/2.0
Step 2: Add module
Download MicroPython module from GitHub: https://github.com/Bhavithiran97/micropython-edubit
Click on the Load/Save button in the editor
Click Show File (1) and Add file button
Add edubit.py to the editor
CODING
To program the EDU:BIT you need to:
- Use
from edubit import *
at the top of your program - Use
init()
inside awhile True
loop to monitor the power switch and reset microbit when power cycled.
Here is the example code for pedestrian crossing traffic light project
from edubit import *
display.show(Image.HAPPY) # show happy face on microbit display
while True:
init() # initialize EDU:BIT
sets_servo_position(S1, position=0) # close the pedestrian gate
sleep(500)
set_led(Red, 0)
set_led(Yellow, 0)
set_led(Green, 1) # traffic light turns green
sleep(2000)
set_led(Red, 0)
set_led(Yellow, 1) # traffic light turns yellow
set_led(Green, 0)
sleep(1000)
set_led(Red, 1) # traffic light turns red
set_led(Yellow, 0)
set_led(Green, 0)
sleep(500)
sets_servo_position(S1, position=90) # open the pedestrian gate
sleep(2000)
UPLOAD
MU EDITOR
Connect EDU:BIT to your computer using a USB cable. Click on the Flash button to upload the program.
Python editor for micro:bit
Connect EDU:BIT to your computer using a USB cable. Click on the Download button and download it into microbit folder to upload the program.
TESTING
Comments