Use what you learned about MicroPython and PyBoard in part one to build this LED flasher project.
In our last post, we introduced you to MicroPython and pyboard. Now it's time to put that knowledge to use by building this LED flasher project!
MicroPython LED Flasher
In testing new development tools and software, it’s quite easy to build an LED flasher for this validation purpose. The hands-on lab concept is to flash two LEDs in sequence while pressing a pushbutton switch. Upon releasing the pushbutton switch, the two LEDs will turn off. I created a block diagram to capture the device’s basic functional design requirements.
The MicroPython LED Flasher block diagram is easily converted into an electrical wiring diagram. The STM32F411RE can source 25mA (milliamperes) of current from each GPIO pin. Therefore, a transistor is not required to drive the LEDs.
Although the electrical wiring diagram shows discrete components, I built the LED flasher device using a Radio Shack Electronics Learning Lab kit. The kit expedited the build of the flasher device because of the pushbutton switch and LEDs provided by the trainer.
Here’s the circuit schematic diagram I created and used to wire the LED flasher device on the Radio Shack Electronics Learning Lab kit.
Figure 8. The MicroPython LED flasher device circuit schematic diagram. View the full-size schematic.
Creating the Code
Developing the MicroPython code for the LED flasher was quite easy based on prior knowledge of the Python language.
This code and pyboard circuit provides a hardware version of the infamous Hello World program used in introductory computer science courses taught in colleges and universities. Not only does the MicroPython code flash the onboard and external LEDs in sequence, but Hello World is displayed on a software communication terminal window as well.
Pressing the first pushbutton switch on the trainer starts the sequencing of the flasher device LEDs.
I was quite pleased with the operation of the pyboard and the ease of use of the MicroPython programming language. This tiny embedded development platform opens a world of project possibilities in areas of environmental sensing, home automation, robotics, and wearable devices. I plan to investigate some of these project idea themes with my electrical systems technology students at the college. Additional information on code examples, programming documentation, and the pyboard component specification can be found at MicroPython’s website.