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 / 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')
@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 / 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 / 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:
from microbit import *
import radio
radio.on()
while True:
msg = radio.receive_bytes()
if msg:
uart.write(msg[3:])
"""
Listen to a connected micro:bit for incoming messages to which you can react
as needs apply.
"""
from serial.tools.list_ports import comports as list_serial_ports
from serial import Serial
def find_microbit():
"""
@ntoll
ntoll / jacques.py
Created March 13, 2017 15:27
Circuit Playground Music in Python
import nativeio
import time
from board import SPEAKER
notes = {
'b': 26,
'a#': 27,
'a': 28,
'g#': 29,
from microbit import *
radio.on()
while True:
if radio.receive():
display.show(image.DUCK)
if accelerometer.was_gesture('shake'):
radio.send('duck')
sleep(20)
import time
print('start')
for i in range(10):
print(i)
time.sleep(1)
print('stop')
@ntoll
ntoll / main.py
Created April 10, 2018 09:57
Attack of the Killer-Cave Plotter from the Planet Raxxla!
"""
Attack of the Killer-Cave Plotter from the Planet Raxxla!
by Nicholas H.Tollervey. Released into the public domain.
Instructions:
Open Mu, put it into Adafruit mode and switch on the REPL
and plotter.