Raspberry Pi day 2: I try to install an application

Yesterday I said I didn’t think there was an easy way of installing new software in the Raspberry Pi version of Debian Squeeze. Well, yes and no. There is a way, but it ain’t easy.

Gimp running on a Raspberry Pi

Installing software in Linux is always a bit of a minefield – it’s easy to get into ‘dependency hell’. Almost all software packages rely on other software packages to be installed before they will run, so you need to use a tool that will handle all this dependency stuff for you. My understanding is that Debian Linux (on which fluffy Ubuntu is based) is pretty good on this score.

The default Debian Squeeze RasPi distro comes with Aptitude for doing this. It’s not exactly a fluffy Synaptic-like experience; it’s a terminal-like thing running in a window, but at least it has menus so you’re not left at the mercy of a blank, accusing command line.

I thought I’d try installing the Photoshop-like image editing software Gimp as my first app. I started up Aptitude, managed to locate the Gimp package (itself no mean feat), selected it for installation and hit ‘g’ to install the packages. No luck. I needed to be logged in as root. The root account is the uber-low level admin account that has rights over everything on a Linux system.

Aptitude lets you ‘go root’ – but it wouldn’t take either of the passwords I could think of. Not ‘suse’ which I used to log in in the first place, nor ‘raspberry’.

Bit of googling revealed that this flavour of Linux has no root password by default. You need to get a terminal (command line) up and type the following:

sudo passwd root

You can then set a password for the root account, which you can give to Aptitude. And that’s how I installed Gimp.

Gimp is very slow – drawing is hilarious. My eldest son drew a wiggly line with a mouse and we watched it try to catch up for a good minute after he stopped moving it. But it works and it does screenshots.

My next objective is to work out how the hell I can download my own photos from Flickr. The bundled Midori web-browser seems to choke on the script on most modern Flickr pages (like the Lightbox) and I can’t find a simple ‘download this image’ on a plain page.

Oh, and I’d like a Twitter client. I’ve heard of one called Turpial but I can’t find it listed in Aptiude. Which will, I suspect, lead me into some editing of config files to get Aptitude to look at software packages other than the default rock-solid, up-to-date, free ones.

Posted in computers, Debian, education, hardware, ICT, Linux, Raspberry Pi | Tagged | 6 Comments

Raspberry Pi est arrivée!

Raspberry Pi est arrivée!
I had joked that the Raspberry Pi was indeed taking me back to the glory days of 1980s computing – mainly by making me wait so long; it reminded me of the interminable delays waiting for Sinclair to ship my ZX Spectrum by mail order.

Today it arrived, and I had almost forgotten why I wanted it in the first place. Here are a few initial reactions and observations:

  • A Kindle charger makes a perfect power supply. You need something with a micro USB plug. Mini USB won’t work.
  • Raspberry Pi

  • It’s a very long way from being a finished product – certainly not for the ‘consumer’ and probably not for an education market yet either.
  • It’s not for the faint-hearted. At the moment I’d say not to get one unless you have at least some experience of Linux. I have a bit of Linux experience and it took me half a day to get it working.
  • Wired (ethernet) internet is very handy, assuming you have the model B. The RasPi has no internal clock, for one thing, and the internet helps it know what millenium it is.
  • Making the SD card with the operating system is a bit of a pig if, like me, you only have Macs and WindowsXP – most of the tools seem to be written for Windows7 and Linux.
  • If you have a Mac, use RasPiWrite from www.exaviorn.com to make your SD card OS. A 4 GB one seemed big enough. [SEE NEW WARNING IN COMMENTS BELOW]
  • Fedora Remix on Raspberry Pi

  • DO NOT (at the time of writing) INSTALL FEDORA REMIX AS YOUR OS. I wasted hours on this. It was buggy beyond belief – forced me to change my password to something stupidly complex and then refused to let me log in. I never got past the login screen.
  • Install Debian ‘Squeeze’ as your OS instead. This is option 1 in RasPiWrite.
  • When you log in at the command line, you need to type startx to get the graphical user interface (windowed desktop) running. This isn’t at all obvious if you’ve never dicked around with Linux before.
  • I don’t think sound works on this default distro yet, and there’s not much software with it. There’s a simple web browser and not much else. I easily managed to find MP3 files on my network (on a USB stick in my router) – but the supplied MP3 player couldn’t produce any audio.
  • I couldn’t see a simple software / package installer for adding software. This is not Ubuntu. As I say, it’s all a bit hard-core nerdy Linux stuff. There is Python and possibly some other tools for programming but nothing terribly friendly-looking.
  • It’s quite slow – but nowhere near as slow as I’d expect a $25 computer to be, and it was driving a 1920 x 1080 display!
  • Debian Squeeze on Raspberry Pi

  • It’s still very early days for Raspberry Pi. Once people start making packages with more fluffy OSs (and perhaps even selling ready-made SD cards tailored to particular uses) this tiny computer will really start to change the world.
Posted in Debian, education, hardware, ICT, Linux, operating systems, Raspberry Pi | Tagged , , | 1 Comment

Télégramme 3

Télégramme Magazine - Issue 3: OUT NOW

Issue 3 of Télégramme magazine is out now. It’s a stunning piece of work by my friend Sarah Hill.

It’s about photography and art, there are articles and interviews, but mostly the pictures just speak for themselves.

The layout is beautiful, and the pictures are amazing, and you can read it for free on your computer. Dive in!

 

Posted in media, photography | Tagged , , | Leave a comment

More Arduino resources

Here are a couple of useful resources for learning about programming and electronics using the Arduino board:

Today I managed to control the brightness of an LED with a flex sensor.

Posted in Arduino, computers, education, hardware, ICT | Tagged | Leave a comment

Arduino exercise 2 – alternate pulsing lights

Having taught our Arduino to pulse a little red LED slowly on and off, and having built the circuit to go with it, we wanted to do something a bit more complex. We considered adding a buzzer, or a button to modify the light’s behaviour – but the simplest next step seemed to be to add a second light, and then get it to behave differently from the first one.

The first decision we had to make was where to start: clearly we had to change the software and the hardware, but which should we do first? I left the choice up to William – he said we should modify the wiring first. Although I feel more secure in the abstract world of code than physical electronic components, this felt right somehow.

Our 2nd Arduino project - alternate red & yellow pulsing lights

So we decided to copy what we’d done with the first LED, only using a new pin on the Arduino board. In our first project we connected a red LED to pin 9, so we chose pin 10 for our yellow LED. There was going to be a bit of a problem completing the circuit, though: we know all electrical circuits have to be complete and circular, and yet the Arduino only has one GND (earth) pin. I described it to William as if we had a battery with two + terminals, but only one – terminal.

Using some vague idea of electronics I must have gained by osmosis (perhaps when I was breathing in all those solder flux fumes as a kid), I created what I confidently called a ‘ground rail’ on the breadboard. This is a common earth line that will complete both our light bulb circuits by connecting them back to the single GND pin on the Arduino.

At this point I had no idea if I was talking complete and utter homeopathy, but I ploughed on regardless.

Arduino project 2

So we rejigged our previous circuit with the red LED, taking a patch lead from the GND pin to a spare row on the breadboard, and then used another patch lead to connect it back to the LED. This spare row became our ground rail.

Arduino project 2

So, for our second LED, we took a jumper from pin 10, connected it to a new 330 ohm resistor, and connected that to one side of a yellow LED. The other side of the yellow LED we connected to our ground rail, to complete the circuit for the yellow light.

William was keen that the two LEDs should be next to each other, so we made the new circuit a physical mirror image on the breadboard of the first circuit.

So that’s the hardware – in theory. Just to check that I’d not gone totally off the (earth) rails, we connected this up to the power with the Arduino running the old code for one LED to see if it still worked. It did. No smoke, explosions – the red LED pulsed and the yellow LED did nothing, as you’d expect; we hadn’t told the Arduino that the yellow LED even existed, let alone what to do with it.

Arduino project 2

So the code… we did this in two or three steps. First we took the ‘Fade’ sample code and tweaked it so that it would control both LEDs in the same way:

/*
 Fade
 
 This example shows how to fade an LED on pin 9
 and another LED on pin 10 simultaneously
 using the analogWrite() function.
 
 */
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup()  {
  // declare pin 9 and 10 to be outputs:
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
} 

void loop()  {
  // set the brightness of pin 9 and pin 10:
  analogWrite(9, brightness);
  analogWrite(10, brightness);
  
  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade: 
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ; 
  }     
  // wait for 30 milliseconds to see the dimming effect    
  delay(30);
}

We wanted to control each LED independently, though. So we had to alter the code so we had two variables, one to describe the brightness of the red LED, and another for the yellow, though at this stage they are both going to always have the same value:

/*
 Fade
 
 This example shows how to fade LEDs on pins 9 and 10
 using the analogWrite() function
 with separare variables for each LED
 
 */
int RedBrightness = 0;       // how bright the red LED is
int YellowBrightness = 0;    // how bright the yellow LED is
int fadeAmount = 5;          // how many points to fade the LED by

void setup()  {
  // declare pins 9 and 10 to be outputs:
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
} 

void loop()  {
  // set the brightness of pin 9:
  analogWrite(9, RedBrightness);
  // set the brightness of pin 10:
  analogWrite(10, YellowBrightness);

  // change the brightness for next time through the loop:
  RedBrightness = RedBrightness + fadeAmount;
  YellowBrightness = YellowBrightness + fadeAmount;
  
  // reverse the direction of the fading at the ends of the fade: 
  // and blink the internal LED on pin 13 at the fade end point
  if (RedBrightness == 0 || RedBrightness == 255) {
    fadeAmount = -fadeAmount ; 
  }     
 
 
  // wait for 30 milliseconds to see the dimming effect    
  delay(30);
}

William asked a rather perceptive question at this point: how does the Arduino know what we mean by ‘redBrightness’ and ‘yellowBrightness’? This was a great opportunity to talk about variables and how you need to declare them at the start of your code – what kind of variables are they? (integers), and what is their initial value? (0, in this case):

int RedBrightness = 0;       // how bright the red LED is
int YellowBrightness = 0;    // how bright the yellow LED is

We uploaded this to the Arduino to test we hadn’t broken anything, and it was fine: both LEDs pulsed in unison.

We then changed the code so that the yellow LED started at full brightness (255) and was gradually reduced in brightness, while the red one, as before, started dark (0) and got made brighter.

We uploaded this code – and as we’d hoped, both lights pulsed alternately:

/*
 Fade
 
 This example shows how to fade an LED on pin 9 up
 while fading a 2nd LED on pin 10 down
 using the analogWrite() function.
 
 
 */
int RedBrightness = 0;    // how bright the red LED is
int YellowBrightness = 255;    // how bright the yellow LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup()  {
  // declare pins 9, 10, to be outputs:
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
} 

void loop()  {
  // set the brightness of pin 9:
  analogWrite(9, RedBrightness);
  // set the brightness of pin 10:
  analogWrite(10, YellowBrightness);

  // change the brightness for next time through the loop:
  RedBrightness = RedBrightness + fadeAmount;
  YellowBrightness = YellowBrightness - fadeAmount;
  
  // reverse the direction of the fading at the ends of the fade: 
  // and blink the internal LED on pin 13 at the fade end point
  if (RedBrightness == 0 || RedBrightness == 255) {
    fadeAmount = -fadeAmount ; 
  }     
 
 
  // wait for 30 milliseconds to see the dimming effect    
  delay(30);
}
Posted in Arduino, computers, education, hardware, ICT | Tagged , | 1 Comment