PFA:005 – Electricity & Arduino Basics




What is electricity?

Ohm’s Law

Ohm’s law is an equation that can be used to calculate the values of the different properties in an electronic circuit.

  • R (resistance) = V (voltage) / I (current)
  • V=R * I
  • I=V / R

This video from Make explains the basics quite nicely:


The image above also visualizes the properties of voltage, current and resistance quite well. (Unfortunately, I do not know the original source of this illustration.)

Here is a good definition of the basic concepts and components you will run into by Tom Igoe


Arduino is an open-source microcontroller platform that is designed to make it easier to work with electronics. It is based on Wiring, a project that originally was heavily inspired by Processing and tried to do the same to hardware as Processing had done to software. If you have a couple of hours, I recommend digging into the history of Arduino and the soap-opera style drama surrounding the recent years.

Right now it’s a bit unclear what is happening with the legal issues etc. But no need to worry, Arduino as a way of working is bigger than the company itself. There are countless similar alternatives that you can use.

How To Get Started?

Download the Arduino software and follow the instructions on the Arduino website if you have problems setting things up. The Arduino boards that you have are Arduino Unos and do not require any driver installation for Mac or Linux. Windows will require a driver.

Getting Started With Arduino from the Arduino website.

Arduino Code Structure

The Arduino software is used to program the Arduino board. You will notice that it is very similar to Processing. The code structure is also very similar. All Arduino sketches need to have the following functions.

  • setup()
    • Runs once when the board starts or is reset
    • You use the setup() for things that you usually only need to do once (like opening the serial port, defining pin modes etc.)
  • loop()


Blinking an LED

Our first program is the one that already comes with your Arduino (if it is a new one). You will see that the little LED on the board marked ‘L’ starts blinking when you power the board. Let’s connect an external LED to see it a little bit better. There is a good tutorial on the Arduino website for this basic example. We will go through the example to check that everything is working properly.

Hook up an LED on the breadboard like this:


Here is the same in schematic view:


And here is the code:


  This example code is in the public domain.

// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     

// the loop routine runs over and over again forever:
void loop() {
  delay(1000);               // wait for a second
  delay(1000);               // wait for a second

Upload your code to the board. Check that you have the correct Board and Serial Port selected from the Tools menu. Go through the getting started part again, if you have problems.

Once you make sure that everything works properly, you can start editing the code:

  • What happens if you change the values inside delay()?
  • Copy and paste more lines to create different light patterns
  • Can you blink SOS using Morse code?