Pi + JavaScript

April 12, 2016

David Crook



The place where code runs
Connected to the physical world.

Single Board Computers

SBC Price
Raspberry Pi Model B+ $25
Raspberry Pi 2 Model B $35
Raspberry Pi 3 $35
Raspberry Pi Zero $5

Many more exist...

Why Raspberry Pi exists

“The idea behind a tiny and affordable computer for kids came in 2006, when [the people behind the Pi] became concerned about the year-on-year decline in the numbers and skills levels of students entering Computer Science at University.”

Paraphrased from Raspberry Pi Foundation - About

Why is it called Raspberry Pi?

"[W]e wanted a fruit name for nostalgic reasons, and the Pi comes from Python" (the programming language) ~ Liz Upton

Raspberry Pi is a trademark of the Raspberry Pi Foundation

Pieces of Pi

The Pi's in front of you are model B+ or model 2 B

  • Connected to 5 watt power supply
  • Connected to wired Ethernet
  • Running Raspbian OS (Debian Linux) on µSD card
  • 40-pin expansion header provides many kinds of I/O ports
    • We are going use some of these today!

Pi Board (B+)

Top view of a Raspberry Pi B+ source

Pi Board (2 B)

Top view of a Raspberry Pi 2 B source

Does it work?

Wireless control from webpage

Web Interface

Why node.js

Node.js JavaScript server running on the Pi

  • single-threaded, event-driven programming model
    • makes it good for low-level programming in many ways
    • resource usage is low
    • fast, even on a tiny computer

Hands-on Portion

  1. Wire it up
  2. Serve it up
  3. It's alive!
  4. Profit

Wire it up

wire it up.
LED info and wiring illustrations
Wiring diagram

Hands-on Demo Pt. 1

serve it to us
SSH instructions [ Markdown version]

                                    open -a Marked\ 2 demo_notes/demo1.md
Network info

DEMO Pt. 2

It's alive!
Auto-slider details [ Markdown]

						open -a Marked\ 2 demo_notes/demo2.md


Authentication and Authorization
Only trusted users can do allowed things
Rate limiting and other checking
Hardware has real-time and real-world constraints
Color calibration
Tweak circuit parameters to resemble color scales
Make it a thing or appliance!
Connect to an external service or control other things
Hacking it
What else can you think of?

Thank you for (not) smoking

David Crook <idcrook@idcrook.com>
Twitter: @idcrook
Github: @idcrook
Blog: github.crookster.org