Armed only with a bucket full of enthusiasm, a wiki full of miss-information and a 2 digit IQ, the good Captain seeks not only to understand the modern world, but also fix one or two bits of kit along the way.

So how does this work?...a short description

The flash.py
program sets the condition of the Raspberry Pi interface (GPIO) so
that output pin 7 is driven high for 1 second, then low for 0.5
second, then the sequence repeats.

When the output is
high, a voltage is applied to the L.E.D. and it lights up.

When the output is
low, there is no voltage on the L.E.D. so it does not light up.

A Long Description.....way too much information

L.E.D. stands for
Light Emmitting Diode, which is a component belonging to the
semi-conductor family. Think of a semi-conductor as a sensitive
component that will only do something exciting if you treat it nice.

Treating an L.E.D.
nice means connecting it the right way around (know as polarity), and
just giving it the right amount of electrical current.

The resistor in
our circuit (which is not a semi-conductor, and therefore is neither
sensitive nor exciting) is the component that limits the current
through the L.E.D. to a safe value. It protects both the L.E.D. and
our Raspberry Pi, so that we don't draw to much current and blow up
the L.E.D. and GPIO components on the Pi.

So, depending how
you treat your L.E.D. the 4 possible outcomes can be summed up as
follows:-

Polarity

Current

Outcome

Correct

The
right amount

WOW!
It lights up!

Incorrect

The right amount

Huh! It doesn't light up

Correct

Too much

Oh no! I've blown it up!

Incorrect

Too much

Oh no! I've blown it up!

So what's
GPIO? In computer jargon, IO means inputs & outputs.

Inputs are used to
connect components such as switches to your computer..

Outputs are used
to connect to components such as lights and motors. So with IO and a
clever program, you could make your Pi detect when a door is opened,
and switch on a light.

GPIO stands for
General Purpose Inputs & Outputs. In fact the individual pins on
the Pi GPIO can be programmed to be either inputs or outputs. The
program line:-

GPIO.setup(7,GPIO.OUT)

...is basically
saying “setup GPIO pin 7 as an output”.

The program line:-

import
RPi.GPIO as GPIO

...is importing a
library of routines and giving it the reference (or name) GPIO. This
allows us to use the clever stuff in this library by using the prefix
GPIO. When we use the instruction:-

GPIO.output(7,GPIO.LOW)

...we are using
the library routine “output” to set pin 7 low (zero Volts), and
when we use:-

GPIO.output(7,GPIO.HIGH)

...we are using
the “output” routine to set pin 7 high (approximately 3.3Volts).

We also import the
“time” library in our flash program, so that we can pause between
switching the L.E.D. on and off. Try changing the sleep values and
see what happens.

What about sudo?

You usually run
your Raspberry Pi as a standard user, using the “pi” account. But
if you try to run the flash program by simply typing:-

python
flash.py

...the display
will say something like this;

RuntimeError:
No access to /dev/mem. Try running as root!

Some operations on
Linux need to be carried out as the “super user” which is a
special administration account, also known as “root”.

The flash.py
program cannot be run as a standard user because (as the message
indicates) standard users do not have access to the /dev/mem
directory.

The solution is to
use the Linux command “sudo” (this is like saying: “as super
user, do this”).

On most Linux
systems, you need to supply an administrator password to use sudo.
But on the Pi things are kept simple, so a password is not necessary.