Build and Test a Pushbutton

As mentioned earlier, sometimes the two pushbuttons on the micro:bit just aren't enough!  If this ever happens with your inventions and prototypes, it helps to be able to add more to a breadboard.  

In this activity, you will:

  • Build and test a pushbutton circuit.
  • Write scripts that monitor the pushbutton circuit through a micro:bit I/O pin.
  • Write scripts that perform different actions that depend on whether or not the pushbutton is pressed.

Parts

These are the parts you will add to the setup you started with in Setup from Previous Activities.

(1) Resistor - 220 Ω  (red-red-brown-gold)
(1) Resistor - 10 kΩ  (brown-black-orange-gold)
(1) Jumper wires - red
(1) Pushbutton - New part, see Pushbutton diagram

A part drawing with numbers by each pin is called a pin map.  Pin maps are normally published in part datasheets.  Engineers and technicians use schematics and pin maps when designing, troubleshooting, and maintaining circuits.  The schematic shows how the parts are interconnected, and the pin map shows how the pin numbers in the schematic relate to the physical part.  This pushbutton can be rotated 180°, and the pin map still applies.  That’s not common!  Most parts have a reference mark by pin 1 and cannot be rotated, for example the two black chips, an 8-pin op amp and a 3-pin transistor from your kit.

Circuit

  • Unplug the USB cable from your micro:bit.
  • Orient the pushbutton so the legs are sticking out the sides of its body.
  • Double check: make sure the legs are coming out the sides, and not the front and back.
  • Set the pushbutton so that it’s legs are ready to sink into these right terminal strip sockets: pin 1 to (e, 23), pin 2 to (e, 25),  pin 3 to (f, 25), pin 4 (f, 23).
  • Press down firmly.  The legs should sink far enough into the sockets so that the pushbutton’s body rests on the breadboard.

 

  • Connected the pushbutton’s lower-left pin 2 to the micro:bit’s P6 pin with a 220 Ω resistor.
  • Connect the pushbutton’s lower-right pin 3 to the right bus strip’s blue (-) column with a 10 kΩ resistor (brown-black-orange-gold).
  • Connect the pushbutton’s upper-right pin 4 to the right bus strip’s red (+) column with a red jumper wire.
  • Reconnect the USB cable to your micro:bit module.