Go to Content


To complete this workshop, you need to have the following equipment:

1x HDMI monitor
1x HDMI lead
1x Keyboard
1x Mouse
2x Power sockets
(one for the Raspberry PI,
one for the HDMI monitor)
1x Ethernet Cable
(to connect to a router)
1x 5v Micro USB Power Cable
1x Raspberry Pi (Model B)
1x SD Card
1x Raspberry Pi Cobbler
1x Cobbler Cable
1x Solderless breadboard
10x Lengths of wire
(red, blue, black, etc.)
1x 10kΩ resistor
1x Tactile push button switch
1x LED
1x Resistor for LEDs
(find out more later)

Preparing your Raspberry Pi

If you were using a different SD card, you would have to install Raspbian, GIT and Node.JS which can take a few hours, so the SD cards have this provided for you.


If you're starting from scratch, you will need to run through the following instructions after installing Raspbian:

curl http://nodejs.org/dist/v0.10.1/node-v0.10.1.tar.gz | tar xz
cd node-v0.10.1
make install

To test if you have installed this properly run this command:

node –v

Node.JS comes with NPM (Node Package Manager) that allows you to retrieve libraries with ease making development much easier; however NPM uses GIT that is not included by default in the operating system. You can download it using the apt-get installer:

sudo apt-get install git


Sometimes called protoboards, breadboards allow to rapidly prototype a temporary electronic circuit. The devices are reusable as they are solderless.

Terminal strips are coloured as red arrows in the diagram and labeled as numbered columns, this is where the majority of your circuit will sit.

Bus strips are the long rails which run across the columns on the site and are generally used for helping power pass through the breadboard.


Firstly we will setup the power to get passed through the breadboard. With your Raspberry Pi, you will generally want to use the 3V3 (or 3.3V) instead of the 5V.

We are using the Raspberry Pi Cobbler as it allows for easier access to the GPIO on the Raspberry Pi.

  1. Slot in your Raspberry Pi Cobbler in to the breadboard.
  2. With red wire, connect your 3V3 to the closest inside bus strip (or on the bus strip with the red line).
  3. With black wire, connect your GND to the closest outside bus strip (or on the bus strip with the blue line).
  4. So that power can be shared on both sides, we can wire the opposing bus strips.

Actuating User Feedback

In this part of the workshop, we will be looking at how to provide feedback to a user when an event occurs.

By the end of this section, you should be able to demonstrate how to complete the following:

  1. Use a breadboard to prototype a basic circuit.
  2. Wire an LED light correctly to the Raspberry Pi.
  3. Calculate resistance values for LEDs.

Light Emitting Diodes

LEDs (as they are commonly known) are simple light modules which you can use to provide feedback in your electronics.

LEDs are polarised, so you must make sure you put them in the correct direction. Reversing the component risks a short circuit. Looking down from the top of the LED there is usually a flattened edge, this identifies the negative pin of the LED.

As LEDs need a specific amount of electricity in order to function effectively, you will need a resistor to limit the amount of power transmitting to the LED. The resistor (more details to follow) can be on either side of the LED.


Resistors limit the flow of electricity in your circuit. If you do not calculate the required amount of resistance, you may cause your LED to burn out.

You will need to calculate the amount of resistance required to run your LED. The amount of resistance will depend on your individual part and each part varies there is no standard value.

This LED resistor wizard will help you find which resistor you should use.

For this example, we can calculate our resistor value. You will need to find your forward voltage and current from your diodes (it should be printed on the packet or included on instructions).

Forward voltage: 2V
Forward current: 20mA
Source voltage: 3.3V
(3.3V is standard for the Raspberry Pi)

Using this information, we would have to use a 68Ω resistor. If you don't have a 68Ω resistor available, you can increase the resistance to a nearby value (e.g.: 75Ω) but do not decrease the resistance (e.g.: 62Ω).

Wiring the LED

We’re going to connect our LED to actuate when we program our commands.

  1. Insert the LED in to the breadboard across two separate terminal strips. Observe which side is positive and place that closer to the Cobbler.
  2. Wire the Cobber pin #22 to the positive pin on the LED.
  3. Connect the negative pin of the LED to the GND bus strip using your 68Ω resistor.

Sensing User Input

In this part of the workshop, we will be looking at how to sense when an event occurs in the real world.

By the end of this section, you should be able to demonstrate how to complete the following:

  1. Wire a tactile push button correctly to the Raspberry Pi.
  2. Extend a prototype on a breadboard.


These push buttons are a simple type of switch that allows an electronic circuit to sense a binary event in the real world (on or off).

The switches we are using today (tactile push buttons) are not like a light switch you'd finder in your house; they're more like door buzzer buttons.


We’re going to add our push button to sense a physical command.

  1. Insert the tactile push button switch across the central gutter of the breadboard.
  2. Wire the Cobber pin #23 to the button leg closest to the Cobber pin.
  3. Connect your 10KΩ resistor from the right side of the button leg to the GND bus strip.
  4. Wire the button leg opposing the resistor to the power bus strip (3.3V)

Tactile push button switches

These are simple components which allow you to change the direction of electrical current.

The orange wire will take either one of two paths:

  1. When the button is not pressed, it will connect to GND (through the 10kΩ resistor); or
  2. When the button is pressed down, it will connect to GND and to 3.3V, but the 3.3V will take precedence.

Doesn’t this cause a short circuit when the button is pressed?

No – this is due to Ohm’s Law: electricity always takes the path of least resistance. Because we placed the 10kΩ resistor between the button and ground, electricity will flow to the Raspberry Pi instead of causing a short circuit.

Programming User Interaction

In this part of the tutorial, we will be looking at how to get your button and your LED to respond to user interaction from a web browser.

By the end of this tutorial, you should be able to demonstrate how to complete the following:

  1. Start using Node.JS to develop web sites.
  2. Develop a basic prototype to sense when the button is pressed.
  3. Respond to events on the website in real-time to actuate electronic components.

Node.JS Dependencies


To start, we need to create a folder that will house our application.

mkdir ~/web-based-phy-comp
cd ~/web-based-phy-comp

To develop the web interfaces for node, we need a few libraries at our disposal to make the process of development easier and to enable real-time communication between our web interfaces and the hardware. Once we've done that, we can create a manifest for our application that will tell Node.JS which dependencies we are using.

This code package.json contains the JSON structure required to start a project and install the required dependencies for this project. We can then run the Node Package Manager (NPM) to install all dependencies:

npm install

Running your code


The code to run this is attached to this document available from GitHub. It is commented to introduce you to developing with Express, EJS, Socket.IO and OnOff.

When you're ready to run your application, go to the application’s root directory and run the following command:

sudo node ./app.js

You can then launch a web browser and go to the following address to start interacting with your circuit: