Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"""
@file bbc_tx
@brief BBC microbit Receiver By Inderpreet Singh
"""
import radio
import random
from microbit import * #import display, Image, button_a, sleep, button_b,
music = False
lights = False
shake = False
count = 0
radio.on()
def toggleMusic():
global music
if music == False:
music = True
radio.send('m-on')
elif music == True:
music = False
radio.send('m-off')
def toggleLights():
global lights
if lights == False:
lights=True
radio.send('l-on')
elif lights == True:
lights = False
radio.send('l-off')
# Event loop.
while True:
if button_a.was_pressed():
toggleMusic()
if button_b.was_pressed():
toggleLights()
if accelerometer.was_gesture('shake') and shake == False:
lights = True
music = True
radio.send('l-on')
radio.send('m-on')
shake = True
count = 30
sleep(1)
if shake == True:
count = count - 1
if count == 0:
lights = False
music = False
radio.send('l-off')
radio.send('m-off')
shake = False
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment