The Start


Hi, What and Why

Compare to Arduino

What do you need to buy ?

It's plugged in, what's first ?

How to install packages.

Recommended packages.

Essential Linux Commands.

How to use the vi editor.

The next step


Set up I2C.

My first program - blink.

VNC - Use your computer to control your Pi.

Samba - copy files.

Raspberry Pi: My First Program.

I hunted online and found a blink program, written in python, that seemed an ideal place to start. You plug in an LED and a resistor and make it flash.

The only sensible way to connect things to the GPIO pins is to buy a breakout board. This was about £6 on ebay. GPIO breakout board

To give you a clear idea of what I am doing - here is my layout. I have my Raspberry Pi plugged in to the power, and am using a wifi dongle to connect to my home network.
Plugged in to the GPIO pins is the breakout board attached to a breadboard; there's a 1K2 resistor and a red LED connected.

My Pi Layout

Note: I have no screen, mouse or keyboard attached to my Pi. I use my desktop PC and VNC to display the Pi GUI on my desktop monitor. See section 'Using VNC' for details.

Hunting on the internet, I found this webpage, which enabled me to copy and paste the python code :

import RPi.GPIO as GPIO
import time
# blinking function
def blink(pin):
        GPIO.output(pin,GPIO.HIGH)
        time.sleep(1)
        GPIO.output(pin,GPIO.LOW)
        time.sleep(1)
        return
# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)
# set up GPIO output channel
GPIO.setup(11, GPIO.OUT)
# blink GPIO17 50 times
for i in range(0,50):
        blink(11)
GPIO.cleanup() 

First, note the command GPIO.setmode. There are two types of pin numbering in use. My GPIO breakout board is labelled with type BCM instead of board, so I changed that - an my LED blinked 50 times as planned.
Also, my board doesn't have 'pin 11' labelled, so I guess that pin 11 is used as something else - pin 21 was labelled, so I changed the code to blink the LED on pin 21.

My aim here is to show you how to set the Pi up for a suitable programming experience. I'm not a python programmer, so I didn't learn much from that blinking code either. However, if you can get this working, then all the other examples and tutorials should help you learn to program in python.

Note on cut and paste : When you read a webpage and copy the code, how do you get it into the Pi ?
Well, if you use VNC and open a terminal and paste text - It won't work.
You have to open a ssh terminal on your own computer - and paste it into a file in that terminal.
So, in my setup, I run ssh pi@192.168.1.184 and log in. Then I vi blink.py and paste the code into that window.