Emojify your Python

Screen shot of Emojifier

I’ve been thinking of ways of sharing Python programs on Twitter and I’ve come up with something a bit crazy, but which might have other uses.

The micro:bit Python emojifier encodes and condenses Python programs using emojis. It also decodes them too, and turns strings of emojis back into full Python programs.

Many keywords are tokenised, in effect, into a single character. This means the programs take up less space, and so you could, for example, share longer programs in a tweet. I used carefully-chosen emojis so even the encoded programs can be read by humans. Our old friend the teleporting duck:

from microbit import *
import radio
radio.config(group=23)
radio.on()

while True:
    message = radio.receive()
    if message:
        display.show(Image.DUCK)
    if accelerometer.was_gesture('shake'):
        display.clear()
        radio.send('duck')

becomes:

🔝
📲📻
📻⚙(👥=23)
📻🔛↩
🔁
〰message = 📻.📥
〰❓message:
〰〰📺💁(🖼🦆)
〰❓📳.was_🤟('🥤'):
〰〰📺🚿
〰〰📻.📤('duck')

I think this might have other uses.

It may also encourage reluctant students to engage with coding concepts by presenting them in a new, but familiar visual language. The emojis are, in effect, a visual abstraction of programming concepts.

Programs written pictorially could appeal to those who struggle with reading or find large blocks of text hard to process, in a way not even block coding can manage,

Maybe students could even write Python programs using emojis. It might make Python more accessible to those who only have mobile devices.

This is very much optimised for Python on the BBC micro:bit, but perhaps it could be applied to other languages.

What do you think? Let me know!

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

micro:bit numbers station

Numbers stations are / were spooky shortwave radio stations, best known from the Cold War, which broadcast human voices reading numbers, usually in groups of five. It’s widely assumed these were / are used by many nations for communicating with secret agents in foreign countries, using an unbreakable one-time pad cipher.

You can spook yourself by listening to The Conet Project.

Or you can code a BBC micro:bit to be come your very own numbers station!

Use one of the micro:bit Python editors (such as the lovely new beta one) to flash the program below on to a micro:bit. If you have a micro:bit V2 you can hear the numbers from the built-in speaker, otherwise attach some headphones or an amplified speaker to pin 0 and GND.

If someone can add some code to play The Lincolnshire Poacher as well, I’d be very happy indeed.

from microbit import *
import speech
import random

numbers = ['zero', 'won', 'too', 'three', 'for',
          'five', 'six', 'seven', 'ate', 'nine']

while True:
    for i in range(5):
        speech.say(random.choice(numbers))
        sleep(500)
    sleep(1000)
Posted in computers, microbit | Tagged , , , , | Leave a comment

micro:bit Wordle game

screenshot of micro:bit Wordle game

I made a Wordle-like game in Python for the BBC micro:bit.

The code is pretty compact and easy to understand, so I think getting students to create their own version of this popular game or pick apart this one would make a nice activity. There are plenty of opportunities to improve it.

You could use it to:

  • teach some Python
  • learn about functions
  • learn about using global variables in functions
  • learn about slicing strings
  • use imports – I hide the word list in an import
  • experiment with the serial console in the new alpha micro:bit Python editor

You’ll need a micro:bit and a Chrome or Edge browser as it uses webUSB – you interact with the micro:bit using your computer’s keyboard and screen.

You get 5 guesses. It shows your progress on the micro:bit’s LED display: a bright LED means the right letter in the right place, a dim LED means the right letter in the wrong place.

It also prints out your progress in the serial console. Capital letters are in the right place, lower case in the wrong place: So

--a-T

means the word ends in T and has an ‘a’ in 1st, 2nd or 4th place.

You can download a hex file to flash direct onto a micro:bit or drag and drop onto the Python editor, plus the raw Python files over on GitHub: https://github.com/blogmywiki/wordobit.

You’ll probably want to add more words to words.py. You could also improve the program in lots of ways, for example add some simple encryption like ROT13 to the word list or add more word checking.

I also made a video to explain how it works and how to play it:

main.py code

from microbit import *
import random
import music
from words import wordlist

def newWord():
    print('New game!')
    display.clear()
    global word
    global turn
    word = random.choice(wordlist)
    turn = 0

newWord()

while True:
    print('Turn',turn+1)
    if turn > 4:
        print('You lose. Your score is X/5. The word was ' + word)
        music.play(music.POWER_DOWN)
        sleep(5000)
        newWord()
    guess = input('What is your guess? ')
    if len(guess) != 5:
        print('Not a 5 letter word!')
    else:
        progress = ''
        for a in range(5):
            if guess[a] in word:
                if guess[a] == word[a]:
                    display.set_pixel(a,turn,9)
                    progress = progress + guess[a].upper()
                else:
                    display.set_pixel(a,turn,4)
                    progress = progress + guess[a].lower()
            else:
                progress = progress + '-'
        print(progress)
        turn += 1
        if guess == word:
            print('Congratulations! Your score is ' + str(turn) + '/5')
            music.play(music.POWER_UP)
            sleep(5000)
            newWord()

words.py code

# List of 5 letter words hidden from main Python program view
wordlist = ['heart', 'aloft', 'float', 'banjo', 'scoop']
Posted in Uncategorized | Tagged , , , , | Leave a comment

Simple micro:bit video out

I love making little computers and getting video out from Arduinos and even micro:bits – IchiconQuest is a lovely self-contained, if eccentric, computer you can make with a micro:bit that has video out.

I stumbled upon the video above remarkably late – it’s just a simple demo by Kevin Moonlight to generate text on an NTSC composite video output on a TV using just a V1 micro:bit and 1 or 2 resistors. I had a go at re-making it, and succeeded!

How to wire up video out from a micro:bit

I’m grateful to @wifisheep for telling me that to make it work better, you should also put a 1K resistor on the red line between the phono and the clip. I had all sorts of weird earth issues without adding that – but still, quite impressive with two resistors.

screenshot of text from a micro:bit

Because very, very accurate timing is so crucial when generating video, the code for this is in C++, not in MakeCode or Python.

You can find the source code and HEX files you can flash direct on to a V1 micro:bit to try this for yourself on my GitHub: https://github.com/blogmywiki/microbit-video

I even made my own font!

wide font on a micro:bit

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

BASYS nostalgia fest

By Jacek Rużyczka - Self-photographed, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=6762692

BASYS was a newsroom computer system used very widely in the 1980s and 90s by many radio and TV broadcasters: the BBC and ITN in the UK, CNN and NBC in the USA, the ABC in Australia and probably many more. It’s been said that it was the invention of BASYS that made pioneering rolling news channel CNN possible.

It ran on central mini-computers connected to ‘dumb’ terminals in newsrooms like the DEC VT420, a beautiful device that could only display text but did so in gorgeous glowing green, orange or white phosphorescent characters on a cathode ray tube display. Many of those terminals ended up in skips, but to buy one on eBay now will cost you several hundred pounds.

I knew BASYS from its special BBC World Service incarnation, EDiT in Bush House in the early 90s. EDiT had a kind of sandbox area called bush.graffiti to encourage reluctant journos to use this new-fangled technology. Odd threads would be started which people would sign with strange pseudonyms. I still have a stack of printouts from bush.graffiti and I wrote about some of them here: http://www.suppertime.co.uk/blogmywiki/2021/07/the-tower-of-babel/

Another killer feature of BASYS was top-line messaging. This was before anyone had broadband internet at home, the World Wide Web was only just being invented and cell phones were certainly not smart, so the ability to send a quick, instant message to your colleagues was intoxicating. I even met my wife in bush.graffiti.

A while ago I asked for help finding info about BASYS as there’s precious little online, certainly no website devoted to it that I could find. Silence. I tried again recently and, maybe because Twitter’s algorithms have changed, I was positively inundated with info.

I’m still looking for any training manuals, preferably ones used to train journalists how to use it. I’d kind of love to make my MUD look like BASYS when you telnet into it…

Here’s a summary of what I’ve learned so far:

Origins

Destiny

  • When the original BASYS company got into trouble, ITN in London bought the company to protect its investment.
    But I didn’t know that…
  • ITN then sold BASYS to DEC. Yes, the computer company that made the mini-computers and terminals the system ran on.
  • DEC then sold it to Avid.
  • BASYS then was ported to Red Hat Linux and lived on for many years as Avid iNews. I checked out some technical manuals on iNews, and it’s really very similar to BASYS indeed, albeit running on Linux servers and at the client end on a Windows app with a GUI featuring buttons.

Hardware

  • @IsItBroke says BASYS at BBC TV new ran on ‘PDP11/54s with IBM ATs each with several serial port cards with VT100 terminals hanging off them (or could be printers or AutoScript promoters which behaves like printers) – these “Terminal Servers” connected to the PDPs over 10Base2 Ethernet.’
  • Originally the BBC’s Basys ran on a pair of Onyx computers but by the time it was being implemented at BBC TVC it was on DEC VAX superminicomputers – possibly 6100s. EDiT at Bush ran on three Vax 6200s. (via @kingsp10)

User interface

  • @mattjones0111 reminded me that although BASYS’s UI was text-only, it was quick to use with its keystrokes and keyboard shortcuts. It allowed horizontal split screens, copy-paste, top-line messaging. Great example of a highly focused UI.

Remote access

  • If you had a modem and maybe an acoustic coupler, you could dial into Basys systems when you were on the road to file your copy and access programme running orders. NBC journalists used Tandy / Radio Shack Model 100 portable computers, and one of my Twitter correspondents @Stephen_Neal used his Psion 5 to dial into Basys at BBC East in 1996.
  • Stephen also writes ‘I used BASYS at the BBC in Norwich and Cambridge 1995-1997. In Norwich it was based around serial terminals, but the new Cambridge newsroom had IP-connected PCs running terminal software. You could connect to the London BASYS system to look at Network running orders.’
  • @mattjones0111 wrote ‘I was a traffic reporter and based at a police motorway control room near Redhill. I had an ISDN line; one channel would connect to BASYS, the other would connect my mic to the studio in Guildford. I also had PSTN dial-up access which I could use from home.’

Trivia

  • It was hilariously easy to send a top-line message the wrong person by getting their username wrong. eg ‘[myeditor] is an idiot, sent to [myeditor]‘ (via @terrystiastny and others).
  • In Bush House, home of the BBC World Service, you could connect to the training system by typing ‘connect train’. The sysadmins changed someone’s password to ‘hacker’ for doing this too often.
  • The BBC World Service Bush House version of Basys was called EDiT.
  • Bush House usernames had 3 letters of surname, a number & 3 letter department code. My own was boo1opr (operations). Amusing ones were rub1pub (publicity) and pis1por (Portuguese for Africa).
  • The Basys console command “msgclean” which could be used to print off every top-line message sent on the Basys system (via @kingsp10)
  • @resourcefulco wrote ‘I was graphic designer on Breakfast Time at BBC Lime Grove, using a Quantel Paintbox. Bored, we tried to link it up to the main PDP-11, and one of the amazing BBC technicians came up with a tiny box that let us do primitive 3-D wire graphics (and slowed down the news autocue)…’
  • Up to v13 of Basys if you took a story which had just been saved in 2 column mode and typed CMD get old, then it would kill all 10 sessions on the CCU to which you were connected. Bug found in v3 and finally fixed in v14 (via @kingsp10)
  • @IsItBroke reported: ‘You could a trick routing a serial port from one Terminal Server to another; it was referred to as a “Permanent Virtual Connection” which we used for router control panels and the like; over the BASYS IP network.’

 

Posted in BBC, computers, media, nostalgia, radio, TV | Tagged , , , | Leave a comment