microbit music

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
kvarneb
Posts: 2
Joined: Mon Mar 13, 2017 2:16 pm

microbit music

Postby kvarneb » Mon Mar 13, 2017 2:46 pm

Im trying to use this code in order to create sound by moving the microbit for a project but it wont seem to work...can anyone please help?

from micro bit import *
import music
on = False
initial = 1000
while True:
if button_a.is_pressed():
on = True
while on:
if accelerometer.get_y() >10:
initial +=100
music.pitch(initial,100)
elif accelerometer.get_y() <10:
initial -=100
music.pitch(initial,100)
else:
music.pitch(initial,100)

if initial >4000:
initial = 4000
if initial < 100:
initial = 100

if button_b.is_pressed():
on = False
sleep(100)

Return to “The micro:bit”

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests