Skip to main content

1.3

Major VersionM

by Pete Prodoehl

Introduction

Connect a pushbutton to a Bit Board and control an LED with it.

We'll explore how we can use a pushbutton as an input for the micro:bit

Video Overview

Featured Document

  1. We'll use Maker Tape to connect the Button and LED to the Bit Board on a LEGO baseplate. We've already connected an LED in Chapter 1 so our new addition this time is the Button.
    • We'll use Maker Tape to connect the Button and LED to the Bit Board on a LEGO baseplate.

    • We've already connected an LED in Chapter 1 so our new addition this time is the Button.

    • We'll connect our LED to Pin 1 and our Button to Pin 4.

    • And of course we'll connect the Ground (GND) sides of each component to Ground 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.

    • While the LED has Polarity our Button does not. If you connect it the other way around it will still work fine. Not all components have Polarity.

  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 Button Hold program: https://makecode.microbit.org/_Psd1HsW3r...

    • This code will turn on the LED while the button is pressed. If you release the button the LED will turn off.

    • We are using a set pull pin block. This will set Pin 4 to up, or high, or 1. (All three terms mean the same thing in this context.)

    • Basically we are turning on Pin 4 by applying a voltage to it. When we press the button we are connecting the pin to Ground and Pin 4 goes to low or 0, which is what we'll look for in our code.

    • In this specific case it could be said we are "pulling the pin to Ground" when we press the button. But don't get up and down when used to describe the state of a pin conflated with the physical "up" and "down" of a button.

    • 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 LED should turn on when the button is pressed and held down, and then turn off when the button is released.

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: 4

Past 30 Days: 13

All Time: 221