You are on page 1of 37

Green means GO with

Fastly!
West Coast HTV SE
Eric Burns
burns@fastly.com

Building Bright Ideas East Coast HTV SE


Darrell DeCosta
darrell@fastly.com

©2020 Fastly, Inc. | Confidential 1


Prepare for the event

To prepare for the event, make sure you have the following ready and available:

➔ Internet access via WiFi network


➔ Monitor or TV with an HDMI port
➔ Zoom-ready access via Wi-Fi network
➔ Power strip or extension cord with 2  3 plugs (long enough to reach your outlet)
➔ An open workspace to set up the Raspberry Pi and breadboard (e.g., a small coffee table)
➔ Your cocktail kit

©2020 Fastly, Inc. | Confidential 2


Instructions and
helpful tips

©2020 Fastly, Inc. | Confidential 3


Steps to set-up Raspberry Pi

➔ Install RPi board into case bottom


➔ Attach heatsinks
➔ Insert MicroSD in the slot on bottom side of Raspberry Pi
➔ Install case middle
➔ Attach GPIO ribbon cable
➔ Connect the Micro-HDMI cable
➔ Connect HDMI cable into Monitor
➔ Connect mouse and keyboard (included with your kit)
➔ Connect Power Adapter to the PiSwitch
➔ Attach PiSwitch to Pi
➔ Power on and wait for it to boot
➔ Connect to Wi-Fi and configure
➔ Start prototyping!

©2020 Fastly, Inc. | Confidential 4


High Level?

➔ Setup RPi, boot and configure


➔ Setup buttons and run input code
➔ Setup LEDs and run output code
➔ Run code that does both input (buttons) and output (LEDs)
➔ Play a game or two!

©2020 Fastly, Inc. | Confidential 5


ESD Warning
Handle with care!

➔ Proper Handling Tips

◆ Only handle PCB by edges


◆ Place PCB on cardboard or bottom of
case
◆ Questions? Ask!

Image by raspberrypi.org, extracted from CanaKit documentation

©2020 Fastly, Inc. | Confidential 6


Step 1
Add RPi PCB into Case

➔ Remove top tier (lid) of case


➔ Pop out the bottom and slip in RPi to
bottom layer
◆ Note: there are two tabs that the PCB slips
under

©2020 Fastly, Inc. | Confidential 7


Step 2
Attach heatsinks

➔ 3 Heat Sinks included in kit


➔ Remove adhesive strip on back and
then place as shown
◆ Larger, square heatsink goes over the
CPU (on left)
◆ Rectangular heat sink goes on the
Memory chip (center)
◆ Smaller, square heatsink goes over the
USB chip (on right)
➔ On rectangular ones - direction of
fins does not matter

©2020 Fastly, Inc. | Confidential 8


Step 3
Insert MicroSD card

➔ Flip the case over to insert MicroSD


card into MicroSD card slot on the
underside of the RPi
◆ From this angle you will be able to see the
SanDisk logo. The contacts will be facing
the RPi board and the narrow end is
inserted first.
◆ Push in until end of Micro SD card is flush
with edge of white case

©2020 Fastly, Inc. | Confidential 9


Step 4
Add case sides

➔ Flip the case back over so USB


ports are to your left and MicroSD
card was inserted on the right
➔ Slide case sides into place

©2020 Fastly, Inc. | Confidential 10


Step 5  Attach GPIO cable

➔ GPIO ribbon cable already on GPIO


adapter and breadboard.
➔ Make sure Raspberry Pi is turned off.
➔ Attach ribbon cable to RPi so that
key (plastic tab) is toward center of
board. It will point at the heat sink
on the USB chip in the center.

©2020 Fastly, Inc. | Confidential 11


Step 6
Connect mouse, keyboard and HDMI cable

➔ Plug mouse into a USB 2.0 port


➔ Plug keyboard into the other USB
2.0 port
➔ This leaves USB3.0 ports open. Any
of the USB ports will work - but best
practice to leave faster ones open.
➔ Plug in micro-HDMI cable into
micro-HDMI port 0 on side of RPi
➔ Connect the other end of the
micro-HDMI cable to HDMI port on
your monitor or TV

©2020 Fastly, Inc. | Confidential 12


Step 7
Connect power supply to the RPi

➔ Plug power supply into outlet


➔ Connect PiSwitch to power supply
USBC end
➔ Insert cable from PiSwitch into
USBC port on RPi
➔ Switch on power and wait for
system to boot

©2020 Fastly, Inc. | Confidential 13


Step 8
Configure the system

➔ Once system has booted, you


should see the Raspberry Pi
Welcome screen
➔ Click “Next” to begin configuring

©2020 Fastly, Inc. | Confidential 14


Step 9
Configure the system

➔ Select a country, language and


timezone
➔ Change Password
➔ Adjust display, if needed
➔ Let system search for WiFi access
points, then select yours
➔ Enter your WiFi password
➔ SKIP UPDATE!

©2020 Fastly, Inc. | Confidential 15


Let’s Build with Fastly

Fun with LEDs and Breadboards

©2020 Fastly, Inc. | Confidential 16


Rapid Prototyping

©2020 Fastly, Inc. | Confidential 17


Breadboard
➔ Remember computer
“bugs” and how they got
their name?
➔ A way to do rapid
prototyping without
soldering
➔ Wooden breadboards are
stable, cheap and solid
➔ Components used to be
huge

Image courtesy of https://tangentsoft.net/elec/breadboard.html

©2020 Fastly, Inc. | Confidential 18


Breadboard
➔ A way to do rapid
prototyping without
soldering.

➔ Designed for low voltage.

➔ “Terminal Strips” are the 5


pin rows. Like 30 a-e or 1
a-e.

➔ “Bus strips” are the power


four that run the full length
in long columns.

Image courtesy of
WikiCommons.

©2020 Fastly, Inc. | Confidential 19


Jumper Wires
➔ A way to do rapid
prototyping without
soldering.

➔ Designed for low voltage.

➔ Red is often used for


positive voltage.

➔ Black is often used for


negative voltage.

Image courtesy of WikiCommons - https://commons.wikimedia.org/wiki/File:FF_Jumper_Wires.jpg

©2020 Fastly, Inc. | Confidential 20


Electricity
➔ Can be AC Alternating Current) or DC Direct Current).
◆ AC switches direction.
◆ DC flows one direction.
➔ Electricity is measured in Volts, Amps and Resistance.
➔ Water in plumbing is a good analogy.
◆ Volts - water pressure.
◆ Current - flow rate. Expressed in Amps.
◆ Resistance - pipe size, perhaps sand in the pipes.
➔ Amperage is what causes the biggest safety risk.
➔ Static Electricity shock is typically 20,000 Volts.
➔ The RPi has 3.3V and 16mA DC connections.
◆ 1020mA  no muscle control is lost.
◆ mA  milliamp, 1/1000 of an amp.
◆ House circuits are typically 15 or 20 amp.

©2020 Fastly, Inc. | Confidential 21


https://commons.wikimedia.org/wiki/File:Breadboard.JPG

©2020 Fastly, Inc. | Confidential 22


Parts to have ready:
➔ 41 Membrane Switch
➔ 1 Resistor
➔ LED Traffic Light
➔ 8 Jumper Wires (you can grab as we go)
◆ 1 Red
◆ 1 Orange
◆ 2 Yellow
◆ 2 Green
◆ 1 Blue
◆ 1 Black

©2020 Fastly, Inc. | Confidential 23


Membrane Switch
4 buttons, 5 wires?

Attach header to ribbon cable

Insert 6 pins into 40j-45j on right side

All of these will be columns f-i on the right side:


(row 40 is empty part of header)
Blue wire 41 to GPIO #12 (row 21
Green wire 42 to GPIO #16 (row 23
Yellow wire 43 to GPIO#20 (row 24
Orange wire 44 to GPIO#21 (row 25
Run Resistor from row 45 to ground rail
(okay on either side - “ground is ground”)

©2020 Fastly, Inc. | Confidential 24


Membrane Switch
4 buttons, 5 wires?

(empty pin on header)


Pin 5  Button #3
Pin 4  Button #4
Pin 3  Button #1
Pin 2  Button #2
Pin 1  Ground

©2020 Fastly, Inc. | Confidential 25


Resistors
Reduce current, colors decodes how many ohms they are

©2020 Fastly, Inc. | Confidential 26


Code for GPIO interactions
Taking input!

Let’s update the code - and glare at Burns for bad script
You can download latest versions from https://github.com/ericburnsonline/Python-RPi-GPIOExamples)

You can “cd” into the Python directory and run


python 1_switch.py

We import libraries to sleep and also use GPIO pins


We use a List to store the pins for the membrane buttons
There is a while loop to count to 10 button presses
We use the position in the list (increased by 1 to get the button position

©2020 Fastly, Inc. | Confidential 27


Most low voltage light bulbs don’t care where
positive and negative wires go.

©2020 Fastly, Inc. | Confidential 28


LED stands for Light Emitting Diode.

Diodes only allow voltage to flow one direction.

LEDs have this functionality, but also light up.

They can only handle so much current and require a


resistor as part of the circuit.

©2020 Fastly, Inc. | Confidential 29


LEDs

©2020 Fastly, Inc. | Confidential 30


LEDs

All of these will be columns a-e on the left side

Insert LED stop light facing to right in 3033e

Black in 30 to Ground rail


Red in 31 to GPIO#17 (row 11
Yellow 32 to GPIO#27 (row 12
Green 33 to GPIO #22 (row 13

If you are out of time - you can plug the LED


assembly into the breadboard up at rows 10a=13a

Resistors?!? These have them built in!

©2020 Fastly, Inc. | Confidential 31


Code for GPIO interactions
Sending output!

You can “cd” into the Python directory and run


python 2_LEDs.py

We have another List for pins


We have a for loop that goes through each item in the List of pins
We set a GPIO pin as either True (on) or False (off), the RPi turns the voltage on or off
accordingly

©2020 Fastly, Inc. | Confidential 32


Code for GPIO interactions
Input and Output!

You can “cd” into the Python directory and run


python 3_switch_LEDs.py

This time the while loop is a “not button4pressed” (which starts as False)
TIMTOWTDI  could be “button4notpressed” starting as True
Example pseudo code similar to “Moria” game from the 80’s:
main() {
while (! dead) {
play();
}
}
We have a for loop that goes through each item in the List of pins
We set a GPIO pin as either True (on) or False (off), the RPi turns the voltage on or off
accordingly
©2020 Fastly, Inc. | Confidential 33
Reaction game . . .

You can “cd” into the Python directory and run


python 4_game.py

Button 1 is for bottom LED


Button 2 is for middle LED
Button 3 is for top LED

Is the code correct?


Notice the game gets faster!

©2020 Fastly, Inc. | Confidential 34


Pimon (Simon) Game . . .

You can get latest copy from:


https://github.com/drldcsta/raspberry_pimon

cd to where you downloaded (probably “~/Downloads”)


mv to where you want to keep the file (perhaps “~”)
Download and unzip (“unzip <filename>”)
For this one - you need to use python3
python3 raspberry_pimon.py

©2020 Fastly, Inc. | Confidential 35


Demo . . . Stats and Instant Config

©2020 Fastly, Inc. | Confidential 36


Thank You!

©2020 Fastly, Inc. | Confidential 37

You might also like