Binary revision activity

I love making teaching resources in Scratch – even better getting pupils to make them too! Here’s a quiz I am going to use even as high as Year 9 to help them revise the binary number system: (requires Flash)

This fits in with the CS Unplugged cards I used to introduce them to binary numbers. Click the green flag and it generates a random 5-digit binary number. Add up the dots to get the decimal equivalent and it shows you the correct answer if you get it wrong. Click the green flag again to have another go. You can also hide the cards to make it more challenging.

I’ve made another project to revise converting base 10 to binary:

Click the green flag to make a random base 10 number, then click the 0s and 1s to flip them until you think you have made the right total. Press ‘check!’ to see if you are right. You can also turn the dot cards on or off depending on how challenging you want it to be.

Of course if the pupils are keen Scratchers they can remix these projects to work with longer numbers or add a scoring system…

Posted in education, ICT | Tagged , , , , , | Leave a comment

Original Macintosh Finder font

Demo of FindersKeepers font

I am a bit obsessed with Susan Kare’s original 1984 Macintosh bitmap fonts and design and made my own Truetype version of her great Chicago font using BitFontMaker.

I then got intrigued by the font used on the labels of items on the Mac desktop – I couldn’t quite figure out which font it was. It was really tiny – about 7 pixels high – and elegant and none of the other default fonts seemed to fit the bill. I eventually worked out that it is actually 9pt Geneva, but the way I worked it out was a bit odd.

I typed all the characters possible in the label on a folder in a 68k Mac emulator and then… I saw a sheep! It turns out I had found an Easter egg! It turns out that the capital letter Y with an umlaut produces completely different pictures at different point sizes:

geneva font easter egg

At 9pt you get a tiny sheep, then as you make the size bigger you get a little Mac, a bird, a bigger sheep and then a running hare or rabbit. I can only assume they were put there by Susan Kare and have been largely ignored ever since!

You can download my TrueType version of 9pt Geneva – which I’ve called FindersKeepers – here.

UPDATE

I’m thrilled to have had this tweet from Susan Kare herself!

Posted in lowendmac, nostalgia | Tagged , , , , , | Leave a comment

Two (3!) new old bitmap fonts

sample of fontsI’m a huge fan of Susan Kare’s work – she designed the beautiful fonts and icons on the original 1984 Macintosh computer, a real work of art. I am always telling my students about this. They probably think I am a little crazed, but I genuinely don’t think a computer GUI has ever been more elegant with so few pixels. Sometimes less really is more.
Screenshot of 1984 Macintosh desktop
Anyway, I got sidetracked today making some of my own versions of her original Mac system font Chicago – the first version I did was a loose interpretation which I call Windy City – it’s bigger and thicker than the real deal and is more like my own Bauhaus font.

I then made a pixel-by-pixel copy of the real Chicago. The letters and numbers are precisely faithful to the original, but the punctuation is largely guesswork. I managed to open some 68k Mac system fonts today – including the ransom-note style San Francisco – but I could not get the bitmap version of Chicago to open in anything. More recent TrueType versions are no good for this.
San Francisco font on OS X
You can download ChiKareGo here and Windy City here. They were both made with the totally awesome BitFontMaker2.

UPDATE

Demo of ChiKareGo font

I’ve now made an even better version of ChiKareGo called ChiKareGo2 – more faithful to the original Chicago font because I have been able to look at the symbols and extended characters in a 68k Mac emulator. I’ve also made the letter spacing 2 pixels instead of 1 to make it look more like the original Macintosh screen (although the original Mac seems to have used kerning! Sometimes it puts 1 pixel space between letters, sometimes 2.) I’ve also included some stripes, a dialogue box close square, 2 shades of shading and even an Apple logo – oddly this seems to be missing from the original Chicago font!

ChiKareGo font map 1

ChiKareGo font map 2

I’m now going crazy trying to work out what the font was on the labels of icons in the Finder – it doesn’t seem to be quite Monaco nor Geneva and I can’t find any reference to it anywhere… my next project is to recreate it…

68k Mac screenshot - Chicago font

Posted in lowendmac, nostalgia | Tagged , , , , , | 2 Comments

The FaderPhone microbit musical instrument

Today I made a (sort of) electronic musical instrument with a BBC microbit and an old BBC radio studio fader.

It’s wired up like I did previously, only I used pin 1 in place of pin 0 – as pin 0 is used for connecting the speaker.

Here’s the Python code, all 8 lines of it – perhaps someone musical can give me better arpeggiator numbers!

from microbit import *
import music

while True:
    fader_reading = pin1.read_analog()
    display.scroll(str(fader_reading),wait=False)
    music.pitch(fader_reading, 100)
    music.pitch(fader_reading+100, 100)
    music.pitch(fader_reading+200, 100)

UPDATE

I’ve now wired up the green cue switch to change the tempo and tweaked the arpeggio notes a bit. The cue switch on the BBC DK4/19 mixing desk was insanely clever. This totally analogue desk let you assign any source to any channel using a rotary selector. The cue switch would then put the appropriate green cue light on if a microphone was selected, start a tape machine if a tape machine was selected, fire off a cart if a cart machine was selected, or signal an outside source (e.g. give a remote studio a red light and put their desk in transmission mode).

Anyway, I digress… I’ve also made the A and B buttons on the microbit stop and start the thing as it does get annoying very quickly.

The circuit now looks a bit like this:

Here’s the new Python code:

from microbit import *
import music
c = 131
e = 165
g = 196
duration = 150
started = False

while True:
    if button_a.was_pressed():
        started = True
    while started:
        if pin2.read_digital() == 1:
            duration = 100
        else:
            duration = 150
        fader_reading = pin1.read_analog()
        music.pitch(fader_reading, duration)
        music.pitch(fader_reading+c, duration)
        music.pitch(fader_reading+e, duration)
        music.pitch(fader_reading+g, duration)
        if button_b.was_pressed():
            started = False
Posted in Uncategorized | Tagged , , | Leave a comment

Add a potentiometer to your microbit

I had a 10k potentiometer lying around that I saved from some junked electronics – it may have been a volume control or something, I can’t remember. Today I found a use for it when I found this excellent web site called Microbit Playground. This shows you how you can hook a pot straight up to a microbit and take readings with a bit of Python. You connect the centre pin of the potentiometer to microbit pin 0, and the other 2 pins are connected to GND and 3v on the microbit. I just used some crocodile clip leads.

I found the code to change the brightness of a dot on the screen needed an int() adding to line 5 so it reads
brightness = int((pin0.read_analog() / 1023) * 9)

I decided to play around with this and did the following:

First I made the display get dimmer or brighter depending on the position of the potentiometer:

Then I made a level graphic go up or down depending on its position in 10 increments:

Next I made a phone-style wedge that goes up & down when you wiggle the knob (just a little bit).

Then with just ONE line of Python I added an analogue paddle controller to my totes awesome Kettle Run game to make… PotKettleRun! (See what I did there? I’m here all week.)

Finally, I wired up a microbit to a fader from an old BBC radio studio mixing desk. This was the main gain fader from BBC World Service studio S36 in Bush House, London. This was a lovely BBC-designed and built DK4/19 mixing desk which we auctioned off for charity in bits when it was dismantled. Note the non-linearity of the fade – one of the nice things about this desk was the sensitivity at low levels allowing for tasteful fades when some other faders fall off a cliff as you get close to 0.

In the highly unlikely event you have a Penny & Giles type 1520/C136/188 fader which you want to wire up to a microbit, the white wire goes to pin 0, green to GND and the brown one to 3v on the microbit:

All Python code at the end of this post. If you make a 2-player Pong game with real physical paddles before me, let me know!

All the Code that’s Fit to Print

Brighter/dimmer screen:

from microbit import *

img0 = Image("00000:"
             "00000:"
             "00000:"
             "00000:"
             "00000")

img1 = Image("11111:"
             "11111:"
             "11111:"
             "11111:"
             "11111")

img2 = Image("22222:"
             "22222:"
             "22222:"
             "22222:"
             "22222")

img3 = Image("33333:"
             "33333:"
             "33333:"
             "33333:"
             "33333")

img4 = Image("44444:"
             "44444:"
             "44444:"
             "44444:"
             "44444")

img5 = Image("55555:"
             "55555:"
             "55555:"
             "55555:"
             "55555")

img6 = Image("66666:"
             "66666:"
             "66666:"
             "66666:"
             "66666")

img7 = Image("77777:"
             "77777:"
             "77777:"
             "77777:"
             "77777")

img8 = Image("88888:"
             "88888:"
             "88888:"
             "88888:"
             "88888")

img9 = Image("99999:"
             "99999:"
             "99999:"
             "99999:"
             "99999")            

img_list = [img0,img1,img2,img3,img4,img5,img6,img7,img8,img9]           

while True:
	brightness = int((pin0.read_analog() / 1023) * 9)

	display.show(img_list[brightness])
	sleep(10)

Levels going up & down

from microbit import *

img0 = Image("00000:"
             "00000:"
             "00000:"
             "00000:"
             "00000")

img1 = Image("00000:"
             "00000:"
             "00000:"
             "00000:"
             "55555")

img2 = Image("00000:"
             "00000:"
             "00000:"
             "00000:"
             "99999")

img3 = Image("00000:"
             "00000:"
             "00000:"
             "55555:"
             "99999")

img4 = Image("00000:"
             "00000:"
             "00000:"
             "99999:"
             "99999")

img5 = Image("00000:"
             "00000:"
             "55555:"
             "99999:"
             "99999")             

img5 = Image("00000:"
             "00000:"
             "99999:"
             "99999:"
             "99999")             

img6 = Image("00000:"
             "55555:"
             "99999:"
             "99999:"
             "99999")  

img7 = Image("00000:"
             "99999:"
             "99999:"
             "99999:"
             "99999")  

img8 = Image("55555:"
             "99999:"
             "99999:"
             "99999:"
             "99999")      

img9 = Image("99999:"
             "99999:"
             "99999:"
             "99999:"
             "99999")    

img_list = [img0,img1,img2,img3,img4,img5,img6,img7,img8,img9]           

while True:
	brightness = int((pin0.read_analog() / 1023) * 10)

	display.show(img_list[brightness])
	sleep(10)

Signal-strength type wedge display:

from microbit import *

img0 = Image("00000:"
             "00000:"
             "00000:"
             "00000:"
             "00000")

img1 = Image("00000:"
             "00000:"
             "00000:"
             "00000:"
             "50000")

img2 = Image("00000:"
             "00000:"
             "00000:"
             "00000:"
             "90000")

img3 = Image("00000:"
             "00000:"
             "00000:"
             "05000:"
             "95000")

img4 = Image("00000:"
             "00000:"
             "00000:"
             "09000:"
             "99000")

img5 = Image("00000:"
             "00000:"
             "00500:"
             "09500:"
             "99500")             

img5 = Image("00000:"
             "00000:"
             "00900:"
             "09900:"
             "99900")             

img6 = Image("00000:"
             "00050:"
             "00950:"
             "09950:"
             "99950")  

img7 = Image("00000:"
             "00090:"
             "00990:"
             "09990:"
             "99990")  

img8 = Image("00005:"
             "00095:"
             "00995:"
             "09995:"
             "99995")      

img9 = Image("00009:"
             "00099:"
             "00999:"
             "09999:"
             "99999")    

img_list = [img0,img1,img2,img3,img4,img5,img6,img7,img8,img9]           

while True:
	brightness = int((pin0.read_analog() / 1023) * 10)

	display.show(img_list[brightness])
	sleep(10)

PotKettleRun game

# PotKettleRun: guide your ship using a potentiometer
# Guide your ship to home port and put the kettle on.
# Can you do the Kettle Run in less than 12 parsecs?
# Sound commands & buttons from original game commented out

from microbit import *
import random
#from music import play, NYAN, POWER_UP, FUNERAL, JUMP_UP, JUMP_DOWN

# edit terrain blocks to make game harder

teacup1 = Image("00000:"
                "99999:"
                "99909:"
                "99999:"
                "99900")

teacup2 = Image("05000:"
                "99999:"
                "99909:"
                "99999:"
                "99900")

teacup3 = Image("00500:"
                "99999:"
                "99909:"
                "99999:"
                "99900")

def teacup_animate(times):
    for x in range(times):
        display.show(teacup1)
        sleep(500)
        display.show(teacup2)
        sleep(500)
        display.show(teacup3)
        sleep(500)

def build_terrain(length):
    canyon_lines=["00000:00005:00055:00555:00055:00005:",
    "50000:55000:55500:55550:55000:",
    "50005:55005:50055:50005:00005:",
    "00055:00555:00005:55000:55005:50005:"]
    terrainString = "00000:00000:00000:00000:"
    for i in range(length):
        z = random.randint(0,3)
        terrainString = terrainString + canyon_lines[z]
    terrainString = terrainString + "50005:55055"
    terrainImage = Image(terrainString)
    return terrainImage

def game_run():
    global level
    global crash
    global speed
    terrain = build_terrain(2+(level*2))
    image_height = terrain.height()
    ship_height = 4
    for i in range(image_height):
        ship_height = int((pin0.read_analog() / 1023) * 5)
#       if button_a.was_pressed():
#            play(JUMP_UP, wait=False)
#           ship_height -= 1
#           if ship_height < 0:
#               ship_height = 0
#       if button_b.was_pressed():
#            play(JUMP_DOWN, wait=False)
#           ship_height += 1
#           if ship_height > 4:
#               ship_height = 4
        if terrain.get_pixel(ship_height, 0) == 5:
            crash = True
            break
        terrain.set_pixel(ship_height, 0, 9)
        display.show(terrain)
        sleep(speed)
        terrain = terrain.shift_up(1)

speed = 500
crash = False
won = False
level = 1

display.scroll('Kettle Run')

while level < 6:         # increase this number to add more levels
    display.show(str(level))
    sleep(1000)
    game_run()
    if crash:
#        play(FUNERAL, wait=False)
        break
    else:
#        play(POWER_UP, wait=False)
        teacup_animate(2)
        display.scroll('Tea up!')
        level += 1
        speed -= 20       # increase this number to speed up more on each level

if not crash:
#    play(NYAN, wait=False)
    display.show('YOU WIN')
    sleep(1000)
else:
    display.show('GAME OVER')
    sleep(1000)

while True:
    display.scroll('Press reset to play again')
Posted in computers | Tagged , | Leave a comment