Standalone microbit scrolling displays

I wanted to make a scrolling display for my desk on parents’ evening, and thought I might use a micro:bit. Then I thought 5 micro:bits might be even better. But how to get them scrolling one message across? I didn’t want to use a computer to control them, I wanted them to be standalone, self-contained. And the radio abilities of the micro:bit mean that no wires should be needed.

So here’s a very simple bit of Python that will turn any number of micro:bits into a rough and ready big scrolling display. There are two different programs, one for the transmitting micro:bit which goes on the right-hand end. Code your message into the Python script and flash it using the Mu editor. When all your other micro:bits are ready, press button A to begin.

--------------------
|RX4|RX3|RX2|RX1|TX|
--------------------

The receiver code goes on all the other micro:bits numbered 1 upwards, lower numbers on the right. Change the number for each device. When powered up they stay blank until they receive the message from the transmitter.

Transmitter code – this goes on the micro:bit on the far right. Code your message in here:

from microbit import *
import radio

message = 'Mr Booth - ICT'

while True:
    if button_a.was_pressed():
        radio.on()
        radio.send(message)
        while True:
            display.scroll(message)

Here’s the receiver code – change the rxnumber for the device number, numbering from 1 on the right, higher numbers as you go left:

from microbit import *
import radio
radio.on()

# set the receive device number here
rxnumber = 1

sleeptime = rxnumber * 750

while True:
    incoming = radio.receive()
    if incoming:
        sleep(sleeptime)
        while True:
            display.scroll(incoming)

UPDATE

Unbeknown to me, Philip Meitiner of the micro:bit Educational Foundation has been working on pretty much exactly the same idea! Can’t wait to see his code as I suspect his is a much more elegant solution:

Posted in Uncategorized | Tagged , | Leave a comment

Book Review: Code Academy by Sean McManus

Code Academy by Sean McManus, illustrated by Rosan Magar.
Ivy Kids / Quarto Publishing, £9.99

This is an intriguing new book to introduce coding to children – there’s no guided age on the back but I think it should appeal to KS2 / 9-11 year olds.

It is beautifully designed, with a good clear layout and attractive illustrations by Rosan Magar. It has a press-out cardboard robot in the front flap, a game poster and stickers at the back that the reader can award themselves as they progress through the exercises. This does make it less useful as a school library text book – it is designed to be written in and each section ends with a certificate that you award yourself. It would, however, make a good present for a child curious about technology and probably work best with a parent or older sibling working through it.

Topics covered include an overview of programming languages, the binary number system, Scratch and HTML, with a welcome emphasis on Scratch. The binary section is short, but strikes me as being a bit odd – it doesn’t really go anywhere and breaks up the flow of the book which builds nicely in the Scratch section through different concepts such as co-ordinates, loops, variables, selection, sprite design and music. I don’t think the binary section would be missed if it were dropped.

I think the focus on Scratch (free, child-centred, widely-supported, works on many devices) is an excellent idea, and I like the inclusion of a section on flowcharts to plan a number guessing game before coding it. It takes the reader through animation, sprite design, planning and making music in a good progression that should be easy to follow and make projects increasingly exciting for children. There is also a web site to offer support where code can be downloaded if readers get stuck.

The chapter on HTML covers the most basic tags, and progresses to add colour using hexadecimal colour codes, which is a nice idea, although it doesn’t explain why #FF0000 is red, #00FF00 is blue etc. This seems like a bit of a missed opportunity to demystify the hex numbers and explain a bit of physics at the same time. Although Javascript is mentioned at the start of the book, there’s no Javascript coding activity in the book, which might have made the HTML a bit more exciting; lack of space and the book’s scope may have made this not possible but its inclusion might have expanded the appeal of the book.

In summary, a well-designed and well-written introduction to coding which could inspire primary-aged children to study computer science in later years, and it will provide a good support to school studies of computing. A timely release for anyone looking for a seasonal gift for a technologically-curious but inexperienced child, grand-child, niece – or for a school prize!

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

Thoughts upon entering a secondhand bookshop

Bought with Loos change

Secondhand bookshops really are the most wonderful things, especially for those, like me, with brains but not brass. It is like being allowed into a salon filled with the greatest minds of our age (Faulkner, Shakespeare, McEwan) whose thoughts you can share for not much more than a hundred pennies.

I wandered in to one such emporium today looking for a sequel. Mr Andrew Millar (who apparently looks uncannily like Rita Tushingham in real life) and some of the other professional readers and writers on his excellent podcast Backlisted said that Gentlemen Prefer Blondes was possibly The Great American Novel, at least a fascinating counterpart to The Great Gatsby, and if Gentlemen Prefer Blondes was the bestselling American novel of 1925, who am I to disagree with the American book-buying public? Anyway I had read and very much enjoyed Gentlemen Prefer Blondes, quite the page-turner and I had no difficulty in finishing it at all, which was a relief because I must say that Mr Millar gets quite cross when people do not finish books they do not like, and I have to say that I think that even I, with my brains, would struggle to finish some of the books that he and his friend Mr John ‘Mitch’ Inson wax lyrical about from time to time.

Reader, you cannot imagine the joy that filled me when, sandwiched between a dozen Alexander McCall Smiths (the proprietor seems only to be on nodding terms with the alphabet), there sat, shyly, a copy of the very sequel to the prequel I had found in this very shop a few weeks previously. Though they have now had the two books by the Loos kind of Anita, it occurred to me that I have never seen a book in there by the other Anita, Brookner (after whom the Brookner Prize is so named.) It is not as if Miss Brookner did not write very many novels, they say she wrote one every summer so as to avoid sunlight, so why do they never have any of them in the shop? I mean, Miss Donna Tartt seems to be just as good at avoiding sunlight and yet somehow manages only to write one book every decade and yet they always have plenty of her novels in this particular shop.

And then I began to wonder if the reason I never find any of Miss Brookner’s books (nor Jane Gardam and scarcely never any of Miss Muriel Sparks’s either) is that they are just too good and people hang on to them. Which means that then most of the books in the secondhand bookshop must, by definition be, at the very best, unwanted if not, at worst, not very good at all. I wondered that as I scanned the shelves crammed with what looked like the complete works of Ian McEwan, Alexander McCall Smith and three identical copies of The Life of Pi. But then there also were orphaned books I love and would have taken home had I not already given home to their identical twins: two copies of The Riddle of the Sands, two copies of The Owl Service, a battered copy of A Fraction of the Whole.

I suppose it just comes down to the fact that one man’s trash is another man’s Treasure Island.

 

 

 

 

 

Posted in fiction, literature | Tagged , , , | Leave a comment

Interfacing Scratch and Python


Hello to Jason Isaacs is the new ‘hello world’.

I decided it might be cool to knock up a simple Scratch interface for the MonkMakes Robot Rover – a bit like the block coding game I made for Year 1 but also controlling a real robot in the real world.

The GPIO commands needed to control the robot directly were going to be a bit heavy and involved, so I decided to see if I could use Scratch to interact with a Python program using the library supplied with the MonkMakes robot. Turns out it’s pretty easy to do this. I’ll write up the robot code later, but here’s a simple example of Scratch interacting with Python.

First I installed scratchpy with
sudo pip install scratchpy

I then opened Scratch and made a very simple program where Scratch cat waits for the message ‘jason’ and replies by saying ‘Hello’. Then I enabled remote sensor connections in Scratch by right-clicking on the () Sensor Value block, found in the sensing category. I then selected the “Enable remote sensor connections” option.

In Python/IDLE 2 I then ran a very simple program to ask your name and broadcast the answer to Scratch. If you replied ‘jason’ you are rewarded with a ‘hello’ back from Scratch cat.

import Scratch
s = scratch.Scratch()
name = raw_input("What is your name? ")
s.broadcast(name)

It’s also possible to respond in Python to messages from Scratch, which I’ll explain next time when we look at the Scratch project to drive a robot round the screen – and a real one round your floor.

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

MonkMakes RasPi Robot Rover Kit review

If you want to cut to the chase, at about 22 minutes in the robot starts moving – much to the surprise of my dog Ellie.

I really liked the Monk Makes RFID Clever Card Kit, so I was delighted when they invited me to review another of their products. The Raspberry Pi Robot Rover kit was an obvious choice as – oddly – I’ve never done any robotics with any of my many Raspberry Pis, and I know this could be a great way to engage young minds.

It currently sells for just under £40 for which you get two pretty tough motors, a tough clear plastic chassis, lots of nuts and bolts, two chunky wheels, a wifi dongle, screwdrivers, battery holder, an ultrasonic distance measuring device – and Monk Makes’ own board which sits on top of a Raspberry Pi’s GPIO pins to control LEDs, the motors and which can also take sensor inputs from switches and the distance sensor.

It took me a couple of hours to assemble the kit – bear in mind I was filming the process which made it much slower. Children would need adult help as some of the steps are quite fiddly, such as bolting the Pi to the chassis and connecting the motors and battery pack to the board requires careful concentration to get the polarities right. Assembly is explained in videos on the Monk Makes web site, though I’d really like to see some written assembly instructions too.

It comes with some sample Python programs. The first ones are projects involving the ‘squid’ button and LED, including a really impressive one where you control the colour of the light by sending tweets. I’m not sure what these have to do with the robot kit, however and I wonder what they are doing in the kit and the manual – perhaps this could be an appendix?

The bespoke board to control the robot is brimming with pins and makes connecting sensors and switches very easy. It’s great to see that the GPIO pins are all carried through, so unlike with many HATs which block off other pins you might still want to use in a project. I suspect this neat little board has many potential uses beyond making a simple robot – anything that needs sensors, switches and requires motors to be powered and controlled in software.

I very much like the way that the robot can be powered from batteries AND the Pi’s USB power supply at the same time, a very good idea for testing and building. If your 6 AA batteries have enough juice you can then disconnect the USB supply and send your robot off into the world on its own.

The programs to control the robot worked well – you can SSH into the robot’s Pi and then control it using arrow keys on another computer. By far the most enjoyable project, however, is the ‘Rover Robot’ program. This sends your robot off exploring its environment and avoiding obstacles using the distance sensor. It worked very well indeed and was great fun to watch.

I’d like to see some explanation of how the core robot Python code works in the manual – I had a quick peek inside and it looked a little opaque, so some more information on how to write your own code to control the robot.

This kit is a good introduction to Raspberry Pi robotics, with plenty of scope for extension activities and I look forward to seeing future iterations of this device and more products from the inventive folk at Monk Makes.

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