Getting Started with MicroPython and the SparkFun Inventor's Kit for micro:bit
Experiment 1: Blinking an LED
This is experiment 1 - blinking an LED. We get to the fun stuff: adding hardware and constructing circuits.
You will need the following parts:
- 1x Breadboard
- 1x micro:bit
- 1X micro:bit Breakout with Headers
- 1x LED
- 1x 100Ω Resistor
- 1x Jumper Wires
Didn’t Get the SIK for micro:bit?
If you are conducting this experiment and didn’t get the Inventor’s Kit, we suggest using these parts:
Before continuing with this experiment, we recommend you be familiar with the concepts in the following tutorial:
- Light-Emitting Diodes — Learn more about LEDs!
Introducing the micro:bit Edge Connector
To extend the functionality of the micro:bit beyond what is already on the board, we developed a breadboard adaptor. This adaptor board makes it much easier to use all of the pins available on the micro:bit edge connector in a more user-friendly way. We also broke out ground and VCC (3.3 volts) for your convenience.
The adapter board lines up with the pins of a breadboard. We recommend using a full-sized breadboard with this breakout to give you enough room to prototype circuits on either end of the breadboard.
Introducing the LED
A Light-Emitting Diode (LED) will only let current through in one direction. Think of an LED as a one-way street. When current flows through the LED, it lights up! When you are looking at the LED, you will notice that its legs are different lengths. The long leg, the “anode,” is where current enters the LED. This pin should always be connected to the current source. The shorter leg, the “cathode,” is the current’s exit. The short leg should always be connected to a pathway to ground.
LEDs are finicky when it comes to how much current you apply to them. Too much current can lead to a burnt-out LED. To restrict the amount of current that passes through the LED, we use a resistor in line with the power source and the LED’s long leg; this is called a current-limiting resistor. With the micro:bit, you should use a 100 Ohm resistor. We have included a baggy of them in the kit just for this reason!
Ready to start hooking everything up? Check out the wiring diagram and hookup table below to see how everything is connected.
|Polarized Components||Pay special attention to the component’s markings indicating how to place it on the breadboard. Polarized components can only be connected to a circuit in one direction.|
Please note: Pay close attention to the LED. The negative side of the LED is the short leg, marked with a flat edge.
Components like resistors need to have their legs bent into 90° angles in order to correctly fit the breadboard sockets. You can also cut the legs shorter to make them easier to work with on the breadboard.
Wiring Diagram for the Experiment
Having a hard time seeing the circuit? Click on the wiring diagram for a closer look.
Running Your Script
Code to Note
pin0.write_digital(1) and pin0.write_digital(0)
You’ll see that is is not much different from the previous experiment except for the lines 8 and 10.
pin0.write_digital(1) sends a HIGH value, ON or a voltage of 3.3V to pin 0 on the micro:bit.
pin0.write_digital(0) sends LOW value, OFF or 0V to pin 0 of the micro:bit.
What You Should See
You should see your LED blink on and off at 1-second intervals. If it doesn’t, make sure you have assembled the circuit correctly and verified and uploaded the code to your board, or see the Troubleshooting section. Change the number in the
sleep() and play with the LED blink rate.
LED Not Blinking
Make sure you have it wired correctly and the correct pin to ground. Remember, short pin to ground; long pin to signal.
Still No Success
A broken circuit is no fun. Send us an email, and we will get back to you as soon as we can: email@example.com