Loving Google’s reasoning for doing this…
An excellent website for a variety of language, including the popular-on-the-Pi, Python.
Ever since going to the TechnoTeach in the Village where someone mentioned you could flash the onboard Status LED from the commandline I wanted to have a go. Instant hardware hacking without waiting for ‘bits’ to arrive.
There’s some guidelines here (ignore the first answer which says ‘not possible’ Those Who Can appear later in the thread. The gist is that it, by default shows the activity on the SD card, but you can override that and control it from GPIO pin 16.
echo none >/sys/class/leds/led0/trigger to turn off the default behaviour echo mmc0 /sys/class/leds/led0/trigger to turn it back on (although I haven't tested that yet!)
Once that’s done you can control it from the commandline using the following commands
echo 1 >/sys/class/leds/led0/brightness will turn the LED on echo 0 /sys/class/leds/led0/brightness will turn it off.
Or to flash it the following module and command will work:
modprobe ledtrig_heartbeat echo heartbeat >/sys/class/leds/led0/trigger
Having got that working to my immense amusement it was time to look at incorporating this into a program.
Python was what most of the examples were written in – something I’d never used. Happily the Raspberry Pi Users Guide was at hand (in Kindle form floating round the classroom on a couple of tablets) and that plus the sample code here was enough to get started.
Initial hurdle was to meddle withe GPIO you need to be running as root and the IDLE ‘Run module’ command doesn’t by default. Relaunching the editor from commandline with sudo sorted that bit.
I fiddled with the sample code to try out timing then started wondering about more uses. Flashing a Morse code seemed the obvious thing to try and since I only know two (BCN or STU for the Brecon and Strumble VORs!) I decided to try and make it flash the code for Brecon.
Things I instantly didn’t know…
How to write to the screen in Python (easy and guessable – print “Whatever”)
The timings for Morse (how much longer than a dot a dash is, how much space is between letters etc. (Wikipedia to the rescue there)
Things that worked well
It worked! and I tweaked it a bit to put some info on the screen as well.
I needed to comment the code heavily to not loose track of which letter I was on.
Stuff to improve /add
More realistic timing. It’s vvveerrryyy veeerryyy slow at the moment 1 second per dit.
Variables for the lengths of the ons and offs. At the moment I’ve coded each characters individually. Very inefficient!
More than one station!
Free text conversion into Morse sequences.
Find out if I can run those commandline setup and close down bits to make the LED accessible from within the program itself.
Code below (I learned about the WordPress shortcode wrapper for posting code without mangling it too!
We have to do this, right??? Volunteers to write an email/letter asking the factory please!
Loads of fun – and real problem solving and purposeful use when using the Pi to get the car to skid better than the human drivers could!
Should we ask for one of these??
Looking for people of all levels to answer some questions!
Guest blog #1: Repurposing a Roomba by Ben J | Raspberry Pi.
Makes me wonder what I’ve got around the house that I can ‘re-pupose’!
Today we looked at breaking down the ideas learners had for what they wanted to do with the Pis into SMART targets.
We’ve looked at SMART targets before as all learners do the Improve Own learning and Performance Key Skill, but most needed to refresh their memory with a quick Google to remember the acronym!
I modelled the process first with a project I fancy having a crack at, and we started working on a collaborative Google doc. Unfortunately although some learners are used to working this way and ready to contribute, a certain amount of silliness did set in with some at the realisation they could tamper with each other’s work. When this didn’t subside in reasonable time and after a warning or two, we decided to have everyone download their own copy to work on and merge them back later. This was more timeconsuming and we’ll have to work on self discipline during collaborative tasks as we go on! Increasingly Google Docs is being used in the workplace and we’d be in a fine old state if the staff all decided to sabotage, rather than improve, each other’s contributions!
It did demonstrate how much of a learning curve there will be and how much targets breakdown needs to be practiced and reinforced.
Some very interesting ideas coming out of it too!