Skip to content

Instantly share code, notes, and snippets.

View ntoll's full-sized avatar
🎵
This statement is false...

Nicholas Tollervey ntoll

🎵
This statement is false...
View GitHub Profile
@ntoll
ntoll / rps.py
Created January 30, 2017 15:39
Rock, paper, scissors
from microbit import accelerometer, display, Image, sleep
import random
pictures = [
Image('55555:55555:55555:55555:55555'), # Rock
Image('50005:05050:00500:55055:55055'), # Scissors
Image('55500:50050:50005:50005:55555'), # Paper
]
while True:
@ntoll
ntoll / ode2.py
Created October 2, 2016 16:11
Harmony line for Beethoven's Ode to Joy. Requires a micro:bit running conductor.py to start.
import speech
import radio
from microbit import display, Image
phrases = [
"#39froyderr " # Freude
"#35sherr#31ner " # schoner
"gerr#35terr#39fuhnx#52kahn" # Gotterfunken
"#62taaaakterr " # Tochter
@ntoll
ntoll / ode1.py
Created October 2, 2016 16:10
Top line of Beethoven's Ode to Joy. Requires another micro:bit running conductor.py to start it.
import speech
import radio
from microbit import display, Image
phrases = [
"#31froyderr " # Freude
"#29sherr#26ner " # schoner
"gerr#29terr#31fuhnx#35kahn" # Gotterfunken
"#39taaaakterr " # Tochter
@ntoll
ntoll / conductor.py
Created October 2, 2016 16:09
The conductor script for starting the other two micro:bits.
import radio
from microbit import button_a, display, Image
radio.on()
display.show(Image.HAPPY)
while True:
if button_a.was_pressed():
radio.send('go')
from micropython import *
import random
dots = [ [0]*5, [0]*5, [0]*5, [0]*5, [0]*5 ]
while True:
dots[random.randrange(5)][random.randrange(5)] = 9
for i in range(5):
for j in range(5):
display.set_pixel(i, j, dots[i][j])
dots[i][j] = max(dots[i][j] - 1, 0)
@ntoll
ntoll / acuity.py
Created February 15, 2016 10:10
A brightness acuity game. See copious comments in-line. Runs on the BBC micro:bit.
# Light acuity game. A pixel will change on either the
# left or the right. Click the appropriate button within
# an ever decreasing amount of time to increase your score.
# The game is over when you get it wrong or don't answer
# in time.
# Based on an idea by Dave Gibbs.
# By Nicholas Tollervey, Feb. 2016. Released to the public domain.
from microbit import *
import random
# Play a game of squeeky pong with a 1m (30 led) NeoPixel strip. :-)
from microbit import *
import music
import neopixel
np = neopixel.NeoPixel(pin1, 30)
def show_pixel(position, wait):
@ntoll
ntoll / pong.py
Created December 27, 2015 16:24
NeoPixel Pong using MicroPython for the BBC micro:bit
# Play a game of squeeky pong with a 1m (30 led) NeoPixel strip. :-)
from microbit import *
import music
import neopixel
neopixel.init(pin1, 30)
def show_pixel(position, wait):
while True:
scroll_string_image(StringImage('HELLO TRANSCODE!'),100)
Verifying that +ntoll is my openname (Bitcoin username). https://onename.com/ntoll