title | layout | meta-description | share | author | about | cats | simple-description | acknowledgements | date | date-updated |
---|---|---|---|---|---|---|---|---|---|---|
Light an external LED on the microbit bit |
text-width-sidebar |
Use electronics and breadboard to light a single LED with the micro:bit. |
true |
jez |
Light a Single External LED. |
external |
LEDs |
Teaser image by Adafruit (CC-BY). |
2016-12-23 10:20:00 UTC |
2016-12-23 10:20:00 UTC |
It's possible to use the external pins on the micro:bit to control external LEDs.
{:.ui .dividing .header}
Electric current can only flow one way through a light emitting diode (LED). It must flow through its anode (+) and out its cathode (-) to light.
The anode has a longer leg and often has a bend in it.
A 220Ω resistor is added to reduce the voltage; without it the LED would blow.
{% include box.html content="which-resistor" %}
{:.ui .dividing .header}
{% highlight python %} from microbit import *
while True: pin0.write_digital(1) sleep(500) pin0.write_digital(0) sleep(500) {% endhighlight %}
{% highlight python %} from microbit import *
fade_amount = 5 # How much to change brightness each iteration speed = 10 # speed brightness changes brightness = 0
while True: brightness = brightness + fade_amount if (brightness <= 0) or (brightness >= 1023): fade_amount = -fade_amount else: pin0.write_analog(brightness) sleep(speed) {% endhighlight %}
Creates a lot of flickering in Python; not quite sure yet.
- Remove the resistor; what happens?
- Reverse the polarity of the LED; what happens?
- Make the LED flash when the button is pushed.