Freedom for all with the Raspberry Pi
User Rating: / 3
Written by Bryce Ringwood   

(Updated 23 Oct, 2012)

The Raspberry Pi is a very inexpensive single-board computer well suited to learning how to program. It is powered by an ARM processor and comes with audio and video output via a jack and phono socket. It also has an HDMI connector. There are two USB sockets for keyboard and mouse and an RJ45 network socket. Physically, it is about the size of a credit card. There are a number of operating systems available, all based on Linux. I originally used the Debian squeeze image superseded by Debian wheezy. I am going to "grey out" the earlier image requirements.  All the software for the raspberry pi is "free".

Free computing means that as an individual you do not have to pay for the software you use. You do not have to go to an app store and pay to download a program (or "app"), and the person who wrote the app does not have to pay the app store owner to have his work there. But wait - there's more! Free computer programs give you access to the source code so that you can modify or use portions of the code in your own programs, which in turn you should make available to others at no expense beyond that of the media. Think of "free" as in your freedom, rather than "free" as in beer. The Raspberry Pi is your open door to the world of free computing. To find out more, please visit the free software foundation's web site.

One intention of the Raspberry Pi is that it should become the computer that today's young adults can learn to use in complete safety. Perhaps it was inspired by products like the Sinclair ZX80, on which students of the 1980s could write BASIC programs. That computer used a Zilog Z80 processor and cost GBP 100.00 (R1300-00) The Raspberry Pi costs about a fifth of this, and has an immensely more powerful CPU. You can purchase the Raspberry pi from RS Electronics.

In addition to the Raspberry Pi itself, you will also need:

  • A USB Keboard
  • A power supply  5.0v at 1.2 Amp with USB connector. (Do not run from a PC USB socket!)
  • A power supply cable (Nokia USB cable)
  • A TV set with AV in or HDMI
  • A USB Mouse (optional)
  • A High Speed SD card with the operating system installed on it.
  • Speakers (optional)

I had to purchase an SD card. They can be bought already imaged, if you don't have a PC or the facilities to do it yourself. I downloaded the Debian image from, and used the suggested diskimager to prepare the card.

The only other thing I didn't have was a suitable TV. Its a pity the Raspberry Pi doesn't have VGA output - but it doesn't because more people have spare TVs than VGA monitors. At least, that must have been the thinking. I bought a Mecer TV tuner (about R250-0), which converts from composite video to VGA (and also turns your VGA monitor into a TV). It isn't a good solution, but working into a TV is something many people might have to do - this is a "pocket money" computer, when all is said and done. 

I had the keyboard, mouse and power supply left over from old computers and cell-phones. A mouse is only needed for the X-Windows system - not for the programs mentioned here.

All that remained was for me to plug it in,  switch it on and wait for the bang. What actually happened was that it simply booted up and worked, and from what I hear, that has been everyone else's experience (bar the odd faulty unit).

Raspberry Pi compared to PIC and Arduino

The Raspberry Pi differs quite considerably from a microcontroller like the PIC and Arduino. Essentially the PIC and Arduino are microcontrollers intended to control the functions of appliances like dishwashers and breadmakers, or maybe industrial processes like mixing concrete. Code is compiled on one machine then the resulting binary is transferred to the PIC or Arduino.

I'm quite certain you could also do this operation on the Raspberry Pi, but you wouldn't normally do something like that. Like a normal PC, the Raspberry Pi has an operating system. The purpose of an operating system is to manage a computer. In the case of our MS-DOS computer, the  operating system generally had to manage a single process (think "application") at a time. Windows XP and UNIX/LINUX based systems can manage many processes simultaneously.  

The operating system also manages the way in which the user interacts or "talks" to the computer. In Microsoft Windows, you generally interact through Windows on a desktop and by using a mouse. You can use a command prompt also. The server versions of Windows (and probably the non-server versions too) allow many users to log on to the server - BUT we just don't work that way very often. We tend to think of Microsoft Windows as one-user-at-a-time. The medium of communication is a command prompt (command line interpreter), or the windowing system.

UNIX and LINUX are a little different. I could have several concurrent users logged on to my Raspberry Pi all happily compiling and running programs from a command line. I guess, in principle you could have several graphical desktop sessions running as well, but to date my attempts at this sort of thing have been "unjoyful". UNIX like operating systems are not limited to a single command line interpreter, or a single windowing system. There are choices. The "normal" command line interpreter is "bash", but you can also use the standard shell "sh". There are others, like "csh" and "ksh" - but they are not implemented on the pi. Other Linux implementations use "kde" or "gnome" as the windowing environment. The pi uses "lxde".

So - yes the Raspberry Pi is a multi-tasking multi-user computer much more powerful than the ones I learned on, and about a millionth of the size. The PIC and Arduino are single-tasking zero-user machines that have their own awesome capabilities. Would I use a Raspberry Pi as part of a battery charger? - probably not. Would I use a PIC? - certainly. Would I learn computer science on an Arduino? - not much. Would I use a Raspberry Pi ? - certainly my first choice, with a PC being in second place. (But, hey, a PC is great for Pastel Accounting -c'mon Sage, when can we have a Linux version?). 

UNIX like operating systems

The thing about LINUX and UNIX is that there are some rules:

  1.  Always shut down before switching off. Not doing this will almost certainly involve an operating system reinstall - inconvenient.
  2. Never log-on as "root" user - -NIX's term for administrator. An inadvertent keystroke can get you into lots of trouble.
  3. Its a pain, but learn the "vi" editor.  One day vi and a teletype terminal might be the only thing you can use to
  4. reconfigure your -NIX commputer and get it to boot properly again after some disastrous event - such as 1. above.

Things you need to do

The Debian "Wheezy" image runs raspi-config the first time you boot. This assists you in setting the time zone, keyboard, and other chores.

The raspberry Pi was designed in the UK, so there are some things that need to be put right for South African users. First of all the keyboard is all wrong and the '@'symbol is where the ' " 'symbol should be and spurious GBP currency symbols also appear.

The time zone is also wrong for South Africa.

Finally, at some point - you will want to switch off - halting the system first. Formerly, you would have to use the "su" command, and elevate yourself to "root" user. New to me is the "sudo" command. Sudo is a utility that allows you to issue a command as if you are root, thus:

pi@raspberrypi:~$sudo shutdown now -h

Which shuts down the system gracefully.

I shouldn't tell you this, but to set the root user password type:

sudo passwd root

You will be prompted for the password and to confirm it. (On my system one of the desktop windows asked for a root password-so I had to do this).

Setting the keyboard to the normal keyboard you use.

If you are in the UK - skip this bit.

At the prompt type:

sudo dpkg-reconfigure keyboard-configuration

You will be bombarded with a lot of questions. Be sure to alter the keyboard to en-US.

Next, alter the time zone (unless you are in the UK):

sudo dpkg-reconfigure tzdata

The answers are "Africa" and "Johannesburg" (Unless you are somewhere else in the world).

Now you can begin to program.

Set the partition size of the root file system to use all the SD card space

Using the "squeeze" image you would have had to use a utility like "gparted".  This would have had to have been from another Linux computer. Normally "Partition Magic" is used. Thankfully, raspi-config does this at boot time. Phew! Thank goodness for that.

Using an editor to write a C++ program

From the command line, there are two (or more) editors available. These are "vi" and "nano". Nano is a simple to use editor, which you should be able to understand without any real tuition. Although there is an improved version of "vi" called "vim", which comes with a tutorial "vimtutor", it is not installed by default. Here, I assume you have only a basic Raspberry Pi installation, with no internet access. I'm going to begin with a very simple program in C++.

At the commmand prompt, type:

vi example.cpp

Here's what you should see:

vi is in "command mode". To put it into "insert mode", type the letter "i", followed by the program text. Note that you may see the word "INSERT" at the bottom of the screen.

Press the [ESC] key to return to command mode. (The [ESC] key always returns to command mode). Now press the colon and then the x character followed by the return key. (The vi command ':x' saves your work and exits vi.) Use the bash command "more" to view the contents of your file:

Next - compile the file using g++

g++ example.cpp

Oh dear!  - we made an error. Under some evil influence, I #included "iostream.h" NOT <iostream> the correct, syntax for C++. Back to vi.

In vi, the 'h','j','k','l' keys are used to position the cursor. The sequence is h,j,k,l for left, down, up, right. Use the 'l' key successively to position the cursor over the first ' " ', then press 'r' followed by '<' to replace the incorrect character. Use the 'l' key again to position the cursor over the next ' " ' and replace it with the correct '>' character. Now use the 'h' key to position the cursor over the '.'. Use the 'x' key to delete (cross it out) it. Why hjkl ? - Well my first UNIX computer did not have arrow keys on the keyboard and hjkl are conveniently placed.

Nothing will happen until you press the 'l' key to move the cursor. Use the 'd' key again to delete the character 'h'. Move the cursor again. Now quit and save using ':x:' Note that in vi, the editing action takes place immediately on pressing the command character - which makes it a very quick editor, once you know it. There's a vi survival guide here.

OK - well, nobody died. If you didn't manage to complete it, delete the file example.cpp using the bash command 'rm' (rm example.cpp) and have another go until you get the hang of it.

All being well, compile and run the program:

The g++ compiler writes to a file a.out. You execute the program by prefixing it witth './' on the command line


Maybe we'll look at the compiler, lineker and other matters in a later article with a more comprehensive example. (After a break of 10 years, my "vi" is a bit rusty too.

Connecting to a network

This is simply a matter of connecting the raspberry pi to your network switch or router using a network cable.

I am using iBurst, and it was as simple as plugging it into my iBurst router. Now you are connected, you can use Midori to surf the web -but beware it is ALARMINGLY slow and may not work with some sites. It does work with this one. Mostly (I think it would fall over with the JavaScript pages). Note that the fonts aren't quite right - long story.

Now you can use 'apt' to install the things you miss most, for example"

sudo apt-get install gfortran
will install the gfortran compiler.

sudo apt-get install vim
will install   vi-improved and the vim tutorial.

Some say 'apt'  (automated package tool ?) is the greatest idea since the invention of radio...

Using the network with your PC

The first thing you need to do is to find your network address:

ifconfig -a

It will be something like

Next, you need to enable ssh (Secure SHell) on your raspi:

First - check if you need to do anything at all! In a dosbox type using your own IP address and port 22 :

telnet 22
If you get a reply involving ssh from the raspi followed by an error message saying protocol not supported- you're OK, but if not you need to enable sshon the raspberry pi. (Telnet was the predecessor of ssh abandoned as being insecure in today's crime ridden society.)

There is a file in the raspi's /boot/ directory called boot_enable_ssh.rc - you need to copy it to the file /boot/boot.rc:

sudo mv /boot/boot_enable_ssh.rc /boot/boot.rc

(The -NIX command 'mv' is short for 'move' - it effectively renames a file.

Microsoft don't seem to have included an ssh client with Windows XP, so you'll need to get one:
On your Windows computer, download putty.exe, and run it. You will get a configuration box for 'session' - all you need do here is enter your raspi's IP address. If you want to run X-Windows on your PC, you need to enable X11 forwarding under SSH->Auth. Save your configuration. Press "Open" and you will get the raspberry pi login in a window.

To run the window manager (LXDE =Lightweight X Desktop Environment), you need to install xming on your PC. Launch xming the way you want it - I use the default, and from your putty window type : (This is the equivalent to typing startx using the keyboard and television)



  • The raspberry pi and linux are about freedom. Your freedom to learn from, and modify programs for your own use.
  • For learning 'C/C++' programming, you only need a power supply,SD card,a keyboard and a TV with the Raspberry Pi.
  • The basic editor for UNIX/Linux is "vi" - learn to love it, but nobody will blame you for using nano.
  • Its still a small computer. Attempting to run OpenOffice on it will end in tears.
  • Use it as a stepping stone to -NIX on large scale systems.

Where to from here ?

LINUX/UNIX has a very powerful command line interpreter compared to DOS. For the programmer, this means that once you have mastered the commmands (and I haven't yet) you have a very productive programming environment - no matter what language you choose. Like DOS, you can write scripts to carry out batch operations. We have already used a script to enable ssh. To get the flavour of shell scripts, you could vi /boot/boot.rc and see the contents.

Maybe we can look at some of LINUX's utilities at a later stage.

The desktop environment is interesting and different from the one I used to use. There are educational games and utilities which should be of use to parents and quite young children.

Yes - its a bit off-topic for this web site, and it really deserves one of its own. Fortunately - there are many, but in this country there are some specific needs to be met. Can something like this replace textbooks - at a fraction of the cost?? Surely it can.

Next - Internet Radio



Joomla template by a4joomla