Skip to main content

1.4

Major VersionM

by Pete Prodoehl

Introduction

Connect four LEDs to a Bit Board and control them with a micro:bit

We'll use the random function to make one LED light up.

Video Overview

Featured Document

  1. We'll use Maker Tape to connect the LEDs to the Bit Board on a LEGO baseplate. Connect the Negative (-) sides of the LEDs to a Ground (GND) hole on the Bit Board. Connect the Positive (+) side of the first LED to Pin 1 on the Bit Board.
    • We'll use Maker Tape to connect the LEDs to the Bit Board on a LEGO baseplate.

    • Connect the Negative (-) sides of the LEDs to a Ground (GND) hole on the Bit Board.

    • Connect the Positive (+) side of the first LED to Pin 1 on the Bit Board.

    • Connect the Positive (+) side of the second LED to Pin 2 on the Bit Board.

    • Connect the Positive (+) side of the third LED to Pin 3 on the Bit Board.

    • Connect the Positive (+) side of the fourth LED to Pin 4 on the Bit Board.

    • You'll notice the Ground on the Bit Board (as well as the LED and other Crazy Circuits components we'll use) is color coded White.

  2. If you've never used a micro:bit before you'll want to check out this guide:  Bit Board V2 Setup and Use
    • If you've never used a micro:bit before you'll want to check out this guide: Bit Board V2 Setup and Use

    • We're going to load the following code for our LED Blink Randomly program: https://makecode.microbit.org/_bJ3PCuadw...

    • This code will generate a random number between 1 and 4 and then light up the corresponding LED. It will then turn off all of the LEDs and repeat the process.

    • At the beginning of our forever block we use a set to function and then add a pick random function to it. We then use an if then block to turn on the specific LED.

    • Finally, we'll use a math function to do some simple division in the last line of the forever block.

    • You'll notice we have a command for led enable set to false in the on start block. The led enable command enables or disables the built-in LED matrix on the front of the micro:bit

    • We need to turn off the built-in LED matrix to properly use Pin 3 and Pin 4 otherwise they will be used by the built-in LED matrix and conflict with our code to control our LEDs.

    • You can see a description of the micro:bit pins here: https://makecode.microbit.org/device/pin...

    • Once the code is loaded it should start running immediately.

    • You can power the micro:bit via the USB cable you used to load the code or you can use a battery pack plugged into the Bit Board.

    • The code will start by choosing a random number between 1 and 4 and then using the if them block will it will turn on the appropriate LED, then turn it off, and repeat.

    • In future guides we'll use four LEDs along with sensors or other input to act as a small bar graph or level indicator.

Finish Line

Pete Prodoehl

Member since: 3/4/20

1,840 Reputation

424 Guides authored

0 Comments

Add Comment



View Statistics:

Past 24 Hours: 0

Past 7 Days: 1

Past 30 Days: 3

All Time: 90