How Do You Solve a Problem Like Lottie?

'What is code?' OMG, I didn't see that question coming. LOL.

I really have better things to do (planning lessons, for example), so much has already been written and tweeted about Lottie Dexter and the Year of Code Car Crash of Newsnight – and yet, and yet…

I hardly ever watch Newsnight these days, but for some reason I was still conscious at 2230. This really was ‘car crash TV’, from the moment she said ‘I can’t code’, followed by the look of mild panic on her face (above) when Paxo asked the utterly predictable question (especially for a professional PR person like Lottie) “what is code?” (Actually, it’s the first question on her organisation’s web site, so you’d think she’d possibly have had a snappier, smarter answer to hand.)

Then there was that smile (below), some say coquettish, some may even say flirty, when Paxo referred to himself and Mark Urban as ‘old duffers’. Paxo’s body language at times resembled someone in convulsions of agony, trying not to look at the person he was interviewing. In the middle of the following item on another topic, Paxo’s mind seemed to be elsewhere when his fellow reporter answered a question and Paxo just sat there saying nothing. “I’m sorry, I thought we were having a film at that point.”

Jeremy, Jeremy, Jeremy, you're not an old duffer. Well, maybe not a duffer.

A few thoughts:

Some of the criticism has valid points, but can be laced with some unfortunate language, eg Donald Clark talks about ‘schoolgirl errors’ and ‘Dottie Lottie’. Tricky ground here. Some unavoidable facts: Lottie is blessed (or cursed) with an interesting name, extreme pulchritude and is at an awkward age.

Lottie Dexter is 24. People may think 9 or 11 or 15 are awkward ages, but not so much has been written about the sheer difficulty of being 24. You’re living in a grown-up world, and yet so much has yet to fall into place, you have so much yet to experience and understand, and yet here you are, suddenly, on national TV facing a grilling from Paxo.

The most interesting critique I’ve seen of Lottie and her Year of Code comes from Adrian Short. He argues that Lottie isn’t the only problem: it goes much deeper. The Year of Code board has no teachers on it, and an amazing lack of any other kind of educator or educational specialists at any level: primary, secondary or university. He has political differences with Ms Dexter (who used to work for IDS’s think tank), but he doesn’t let those get in the way of a well-argued dismantling of the Year of Code’s leadership and purpose. Well worth a read.

I’d never even heard of The Year of Code until the morning of the fateful News Night to follow. I was about to send their leaflet round to ICT folk in my school, but after seeing Newsnight, was glad I didn’t.

At times it seems like the world of computing education is going to kill itself through in-fighting, bandwaggon-jumping, hoopla and distractions like Lottie Dexter (it’s not just Paxo who got himself distracted) – and I really, really should be planning lessons (or making a cool new Raspberry Pi gizmo with my daughter – details to follow!) not writing this. There’s so much guff out there, what’s a poor educator to do?

Well, this may help: Code Club have launched Code Club Pro. It’s CPD for teachers. It seems practical. It looks like it could actually help you deliver the, you know, new curriculum. To schoolchildren.

I’m excited and exasperated all at once. The new computing curriculum was one of the things that made me want to retrain as a teacher in the first place, and I’ve kind of lost sight of that, partly through the sheer workload of training in and learning to teach every other subject, but also because of in-fighting among those who claim to be helping kids code.

What did YOU do in the great school code war, daddy?

Topper Headon of The Clash was on Cerys Matthews’ BBC 6Music show this morning. He only took up drumming because a broken leg stopped him playing football. He said everyone has a talent; he was lucky enough to find his. A listener asked what he would be if he weren’t a drummer. “A failure,” he replied. “Drumming is the only thing I’m any good at.” (He wrote the music for ‘Rock the Casbah’, so that’s not quite true, but you get the point).

I know writing a bit of code won’t turn anyone into the next Zuckerberg, but as I think I said at my original job interview, it might just help a few children find something they excel at and which can have career, and life-changing, consequences. My eldest son is at secondary school, specialising in ICT, where his most recent ICT lesson consisted of having to write about ‘the advantages and disadvantages of online shopping’ – surely even a few lines of code, anything to teach concepts of flow and control, would be an improvement on this?

My happiest moment this term was seeing a child who struggles with some more traditional areas of the curriculum suddenly become an expert when were were looking programming and designing in Scratch. He was helping others. He was motivated. He was learning. He had a big grin on his face. And you can’t ask for more than that.

Posted in computers | Tagged , , , , , | Leave a comment

Controlling Raspberry Pi from £29 Nook e-reader

I installed ConnectBot on my rooted £29 Nook e-reader – and I can log into my Raspberry Pi radio from anywhere in the house using ssh. And change the station in the kitchen. Mwa-ha-ha.

Posted in Linux, radio, Raspberry Pi | Tagged , , | Leave a comment

Quick and dirty Raspberry Pi radio scheduling

Many thanks to James West for putting me onto this: http://www.bbc.co.uk/rd/blog/2013/09/prototyping-radio-experiences-with-radiodan and http://radiodan.github.io/. A lot of this seems quite complex – I like really, really simple things – but it’s got me thinking about building my own simple radio schedule, changing the channel for programmes I know I don’t want to miss.

It occured to me that I could use cron to do some really simple radio scheduling of my own on one of my Raspberry Pi radios – either the simple one or the sexy one. I tried it, and it works! I am my own scheduler: I never need miss treasured programmes again, nor indeed have to listen to ones I detest (I’ll refrain from naming any, but the words ‘hilarious opening montage’ spring to mind).

All you have to do is type

sudo crontab -e

at the command line and then add a line like this at the bottom of the file, remember to press return to make a new line at the end, and save it:

0 14 * * 5 mpc play 5

This will play Wittertainment every Friday at 2pm! Or, try this:

0 12 * * 1-5 mpc play 5

which will make sure you never miss Shelagh Fogarty‘s programme.

You can use a cron job generator like this to generate the crontab codes for you.

Next I need to tweak my LCD radio code to display the station that’s been played by the sheduler, but even so the buttons still work, so if you don’t like the scheduled programme, you can still over-ride it.

UPDATE

One way of getting the scheduled radio event to update the LCD display might be to run another script at the same time, so the cron entry would look something like this:

0 14 * * 5 mpc play 5 && /home/pi/schedLCD.py

The schedLCD.py script would look something like this:

#!/usr/bin/env python

import os
from nanpy import Arduino
from nanpy import (OneWire, Lcd)

# configure pins for Hobbytronics LCD shield
lcd = Lcd([8, 9, 4, 5, 6, 7], [16, 2])

L= [S.strip('\n') for S in os.popen('mpc').readlines()]
sttn = L[0][0:15]
lcd.printString(16*" ", 0, 0)
lcd.printString(sttn, 0, 0)

Not sure if this would conflict with the other Python script running the radio – I’ll have to try it!

Posted in Arduino, hardware, Linux, radio, Raspberry Pi, Raspbian | Tagged , , , , | Leave a comment

Scrolling LCD text on Arduino/Raspberry Pi

As part of my Raspberry Pi/Arduino internet radio project, I’m tinkering with getting the display to show something other than the station name and the time and date – the weather, for example.

Now we’ve been having quite a lot of weather lately, and sometimes it won’t fit in the 16 characters my LCD display will show at a time (at least on one line).

My display is an Arduino shield, and I’m using nanpy to get the Raspberry Pi to send text to the display and read button presses. I couldn’t work out if nanpy supports LCD scrolling, so I’ve written a function of my own that takes a string; if it’s 16 characters or less, it just displays it on the bottom line of the LCD. If it’s longer than 16 characters, it scrolls it across the display and then leaves the first 16 characters on the screen. This means the function finishes running and you can get on with something else.

Here’s the Python code for scrolling text on an Arduino LCD controlled via nanpy (weather code will follow, but I have it working!). I added the extra space to the end of the text being scrolled, as without it, it seemed to leave a trail of the last character.

import string
import time
from nanpy import Arduino
from nanpy import (OneWire, Lcd)

# set up Hobbytronics Arduino LCD shield
lcd = Lcd([8, 9, 4, 5, 6, 7], [16, 2])

def scrollText( scrollBlurb ):
   if len(scrollBlurb) > 16:
     padding = " " * 16
     oldText = scrollBlurb
     scrollBlurb = padding + scrollBlurb + " "
     for i in range (0, len(scrollBlurb)):
      lcd.printString(scrollBlurb[i:(i+16)], 0, 1)
      time.sleep(0.35)
     lcd.printString(oldText[:16], 0, 1)
   else:
     lcd.printString(scrollBlurb, 0, 1)

scrollText("some very long text that won't fit on the screen")
Posted in Arduino, Debian, Raspberry Pi, Raspbian | Tagged , , , , , | Leave a comment

Fip Radio

I was tinkering with my Raspberry Pi / Arduino internet radio, and stumbled upon David Hepworth talking about Fip radio. This is France Inter Paris, which plays ‘French chanson, jazz, world music, film soundtracks, alt.rock and the occasional blast of classical music’ (according to The Guardian). I suspect that the French spoken links are at least as appealing as the music. So I added Fip to my roster of radio stations on my Raspberry Pi by typing
mpc add http://mp3.live.tv-radio.com/fip/all/fip-32k.mp3
at the command line. Up until now I’ve mostly been listening to BBC stations I can hear on DAB, so it’s nice to have a station I could only listen to on the internet – makes the project more worthwhile. I could still do with some more interesting internet stations – any suggestions?

I also tweaked the Python code for the radio player itself to account for the extra station – there are 8 on my radio not 7 now.

I also added some code to remember which station I was listening to last time, so that when I turn it on it’ll play that station, which is what most real radios do. It stores the station number in a file called station.txt every time you change channel.

Here’s the code below for lcd-soundsystem.py, which is in my /home/pi directory. It’s run when I turn the Pi on by adding the line
(sleep 65; python /home/pi/lcd-soundsystem.py)&
to /etc/rc.local. The ‘sleep 65′ is needed because I’m using wifi, and it takes an age (well, over a minute) for the wifi network to come up.

The radio itself was made by plugging an LCD shield into an Arduino Uno, plugging that into a Raspberry Pi’s USB socket. The Pi has music players mpc and mpd installed, plus nanpy, which allows the Pi to talk to the Arduino. The up and down buttons on the display change the channel up and down, left and right decrease and increase the volume and the SEL button acts as a pause / mute. At the moment the PAUSE display is over-written by the clock thread – I need to work out how to get the clock thread to know what state the pause button is in.

(NB – this code below was updated May 2014 – click here.)

#!/usr/bin/env python
import time
import os
import thread, itertools
from nanpy import Arduino
from nanpy import Lcd

# configure pins for Hobbytronics LCD shield
Arduino.pinMode(0, input)
lcd = Lcd([8, 9, 4, 5, 6, 7], [16, 2])

# read station number from text file
f = open('/home/pi/station.txt', 'r')
station = int(f.read())
f.close

# threaded function to show time twice a minute
def showTime():
   while True:
       now = time.localtime(time.time())
       lcd.printString(time.strftime("%H:%M   %d/%m/%y", now), 0, 1)
       time.sleep(30)

lcd.printString("MyLittleRadio1.3", 0, 0)
lcd.printString("by @blogmywiki  ", 0, 1)
time.sleep(2)

def getKey():
   val = Arduino.analogRead(0)
   if val == 1023:
      return "NONE"
   elif val < 100:
      return "RIGHT"
   elif val < 200:
      return "UP"
   elif val < 400:
      return "DOWN"
   elif val < 600:
      return "LEFT"
   elif val < 800:
      return "SEL"
   else:
      return "KBD_FAULT"

def getTrack():
  L= [S.strip('\n') for S in os.popen('mpc').readlines()]    # Get the Track info from the stdout of the mpc command
  sttn = L[0][0:15]                                                         # Pick out the Station and Track info
  lcd.printString(16*" ", 0, 0)                                            # Send it out to the LCD Display
  lcd.printString(sttn, 0, 0)
  print L
  print sttn

# station = 4
os.system("mpc play " + str(station))
getTrack()
pause = 0

# start a new thread for displaying time
thread.start_new_thread(showTime, ())

while True:
  #take a reading
  key=getKey()
  if key == "UP":
    station += 1
    if station > 8:
       station = 1
    print(str(station))
    os.system("mpc play " + str(station))
    getTrack()
    f = open('/home/pi/station.txt', 'w')
    f.write('%d' % station)
    f.close
  elif key == "DOWN":
    station -=1
    if station < 1:
       station = 8
    print(str(station))
    os.system("mpc play " + str(station))
    getTrack()
    f = open('/home/pi/station.txt', 'w')
    f.write('%d' % station)
    f.close
  elif key =="LEFT":
    os.system("mpc volume -3")
  elif key =="RIGHT":
    os.system("mpc volume +3")
  elif key == "SEL":
    if pause == 0:
      pause = 1
    elif pause == 1:
      pause = 0
    os.system("mpc toggle")
    if pause == 1:
      lcd.printString("      PAUSE     ", 0, 1)
    elif pause == 0:
      noo = time.localtime(time.time())
      lcd.printString(time.strftime("%H:%M   %d/%m/%y", noo), 0, 1)

# added for key press debounce
  time.sleep(0.1)
Posted in Arduino, Raspberry Pi | Tagged , , | 5 Comments