Modify these files using nano e.g. sudo nano /etc/inittab make the changes then CTRL+X and Y to save the buffer.
You’ll need to use sudo since these files can’t be written with standard privileges.

Now reboot (sudo reboot) and check the system boots back up okay.

By default the ATMEGA328P chip should have the Arduino bootloader and standard Firmata software flashed (more on this later if it’s not). Having Firmata installed means you can control the inputs and outputs via Python pretty easily.

Disconnect the power and plug the PiMagic onto the top of the Raspberry Pi. Be careful to ensure that the header is not offset. Also be careful to ensure the power is disconnected when plugging or unplugging the PiMagic.

Connect an RGB LED with anodes to pins D3,5,6 via 220R resistors and the cathode to 0V. A breadboard setup should look something like this (you can’t see where the black wire goes in this picture but it’s back to 0V on the PiMagic)

Now power back up your Raspberry Pi and log in as normal.

On the PiMagic, the onboard green LED indicates power. The orange LED is connected to D13 and may blink a few times on initial boot (showing Firmata is active).

To run the code:

python firmata_rgb.py

… and you should see pretty colours cycling around randomly !

Getting started with the PiMagic– PiPong with analogue paddles

Pong is not only a classic game, but a frequently used tutorial for getting started in game authoring using Python and the Raspberry Pi. However, I thought it was lacking something… control of the bats using old-school analogue paddles rather than the keyboard. In this section we’re going to use the analogue inputs of the PiMagic to read analogue voltages from two potentiometers (the paddles) and use this to control the bats.

First of all, Pong is a graphical game, so fire up the GUI from the command prompt with startx

I think Geany is a much better development environment than IDLE so start a LX Terminal prompt and enter sudo apt-get install geany to install this environment. When done Geany will appear under the Programming menu with the other tools.

Now wire up some potentiometers so that the wiper is connected to an analogue input (e.g. A0), and the extreme ends are connected to 5V and 0V on the PiMagic. That way as you rotate the pot to move the bat, the output varies linearly from 0V to 5V. The potentiometers should be single-gang, linear types with a resistance value in the range of 1k to 50k (I used 10k).

Here’s a few pictures of the potentiometers cabled up and mounted in small hand-held plastic boxes. Note that I cut and used some link wires to make convenient pins for plugging into the PiMagic headers – the 0V (screen of the cable) and 5V (red wire) are paralleled up to make easy the connections.

Once the hardware is up and running, you can download the source with the following command…