Script: led_brightnesses
This script sets a light to ⅛, ¼, ½, and full brightnesses.
- Enter the led_blink script (python.microbit.org/v/2 matches the screencaptures).
- Set the Script Name field to led_brightnesses.
- Click Load/Save, and then click Download Project Hex to save your work. Close the Load/Save dialog box after downloading.
- In the python.microbit.org editor, click Connect, and then click Flash.
# led_brightnesses
from microbit import *
while True:
pin14.write_analog(128)
sleep(1000)
pin14.write_analog(256)
sleep(1000)
pin14.write_analog(512)
sleep(1000)
pin14.write_analog(1023)
sleep(1000)
Test the LED Brightnesses
- Look straight down at the top of the LED’s dome, and verify the four different brightnesses.