Blink

In this activity, you'll learn how to make your LED light blink.

micro:bit Set-up

Before writing code in MicroBlocks, set up your micro:bit on a piece of paper. Use two pieces of copper tape to make your connections. One piece of tape will start at pin 0 and the other will start at GND.

  1. Place two pieces of copper tape on the micro:bit on a piece of paper.
  2. microbit with copper tape prepared

Test Code

Test your set up by adding an LED with the following starting code. Make sure that the positive side of the battery is connected to pin 0 and the negative side of the LED is connected to GND.

  1. Add an LED to your copper tape circuit and test that it turns on with this example code.
  2. microbit turns on LED forever loop set digital pin to 0

Blink Code

After testing that your LED turns on, you'll modify to the code so it blinks on and off. The code from the test uses a block set digital pin ... to ... which controls when electrical current is sent into a specified pin. Choose which pin to send current (0, 1, or 2) and whether there should be current (green toggle for on, red toggle for off).

  1. Modify the test code to turn the LED on and off.
  2. code blocks for blinking LED
  3. Test with micro:bit by plugging it into your computer. Click for a video.
    blinking LED
Explore other blink patterns. Create custom on-and-off sequences using the set digital pin block. Once you have a custom blink pattern, use one of the micro:bit inputs from a previous lab to start turn on your light.
In this activity, you learned how to make an LED blink with code.