Hardware Week 2: Beyond the Board

Now that we understand the board a bit, let's start to extend it.

GA CCI Hardware Week 2

Questions from last week?

Highlights from Saturday?

GA CCI Hardware Week 2

Class Overview

  • Circuit basics - from the beginning
  • Extending the board with your own buttons
  • Working with Wires
  • Arcade Buttons
  • Making them "permanent"
GA CCI Hardware Week 2

Circuits: little loops of electricity

GA CCI Hardware Week 2

Make your "simplest circuit"

GA CCI Hardware Week 2

Make a slightly less simple circuit

GA CCI Hardware Week 2
GA CCI Hardware Week 2
GA CCI Hardware Week 2
GA CCI Hardware Week 2

Everything can be a switch

Can you make a novel switch or button?

GA CCI Hardware Week 2

Exercise: Make it your own.

Make a paper circuit of your own design!

Everything can be a button.

GA CCI Hardware Week 2

Share what you made!

GA CCI Hardware Week 2

This works with our boards too!

We can extend our microcontroller/board with circuit parts of our own.

GA CCI Hardware Week 2

First, let's load this onto our board

import digitalio
import board 
import time 

led = digitalio.DigitalInOut(board.D13)
led.switch_to_output()

button = digitalio.DigitalInOut(board.A1)
button.switch_to_input(pull=digitalio.Pull.DOWN)

while True:
    if button.value:  # button is pushed
        led.value = True
    else: 
        led.value = False
    
    time.sleep(0.01)
GA CCI Hardware Week 2

Connect one alligator cable to A1, and the other to 3.3v. This is ... a switch?

GA CCI Hardware Week 2

A sidebar on Pull.UP and Pull.DOWN ...

GA CCI Hardware Week 2

Pull-down

Pulling down the pin means your default value is LOW, or 0.

When you pull a pin DOWN, the other side of the button has to be attached to 3.3V (a positive terminal) to be evergized when the button connects.

When the button is pushed, the value goes high.

Pull-up

Pulling up the pin means your default value is HIGH, or 1.

When you pull a pin UP, the other side of the button has to be attached to GND (a negative terminal) to be grounded when the button connects.

When the button is pushed, the value goes low.

GA CCI Hardware Week 2

Try swapping Pull.DOWN to Pull.UP. What do you need to change to get the LED to turn on when the button is pushed?

GA CCI Hardware Week 2

Ok, go ahead and switch back to Pull.DOWN!

GA CCI Hardware Week 2

Let's swap those alligator cables for something with a sturdier connection.

how to strip wires - reference

GA CCI Hardware Week 2
GA CCI Hardware Week 2

We'll use M3 bolts & nuts to secure these wires.

Once you replace the alligator cables with these, test them out by touching them them together.

GA CCI Hardware Week 2

A switch or button can be anything that connects two parts of a conductive circuit.

So, let's get creative with this!

Get Back To Work

Electronic Popables by Jie Qi

Kandenko "Future with Bright Lights

Kandenko "Connecting Thoughts"

GA CCI Hardware Week 2

Make a novel button and hook it up to your board.

Can you make its form relate to its functionality? Can you make it functional, dysfunctional, or otherwise odd?

GA CCI Hardware Week 2

And now for something more "official"

Let's attach an arcade button.

Adafruit arcade button

GA CCI Hardware Week 2

On an arcade button, you'll see 4 terminals at the bottom. On these buttons, the 2 attached to the gray square are the terminals connected to the actual button.

Connect one alligator clip to each of these terminals.

GA CCI Hardware Week 2

Using the same code this should work!

Attach:

One terminal → A1

Other terminal → 3.3V

GA CCI Hardware Week 2

How could we make this more permanent?

GA CCI Hardware Week 2

We're going to replace our alligator clips with soldered wires.

Solder Demo Time

ifixit how to solder video

simple wire-to-wire soldering

GA CCI Hardware Week 2

First, prep your wires.

You'll need a pair of wire strippers, and 2 wires of different colors.

GA CCI Hardware Week 2

Soldering your two wires to these two connections:

GA CCI Hardware Week 2
GA CCI Hardware Week 2
GA CCI Hardware Week 2

Now, connect these to A1 and 3.3V using M3 bolts.

Running the same code, the button should work!

GA CCI Hardware Week 2

What are these other pads?

These buttons have LEDs built-into them so that they can light up when you want them to.

GA CCI Hardware Week 2

Let's do the same thing: cut some wires, solder them to these terminals.

GA CCI Hardware Week 2

Attach the following using M3 screws

+ → A2

- → GND

GA CCI Hardware Week 2
import time
import board
import digitalio

BUTTON_PIN = board.A1
LED_PIN = board.A2

button = digitalio.DigitalInOut(BUTTON_PIN)
button.switch_to_input(pull=digitalio.Pull.DOWN)

led = digitalio.DigitalInOut(LED_PIN)
led.switch_to_output(value=False)

while True:
    pressed = button.value
    led.value = pressed
    time.sleep(0.1)  
GA CCI Hardware Week 2
  1. Can you make this button turn the light on with a push, and off again with a push?

  2. Go back to some code from last week, and use this button to control the neopixels.

GA CCI Hardware Week 2