microbit micropython help
Posted: Mon Mar 13, 2017 2:36 pm
Hi
I am currently trying to use this code in order to create different sounds when the microbit is tilted in a different direction. However, it isnt working...can anyone 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)
I am currently trying to use this code in order to create different sounds when the microbit is tilted in a different direction. However, it isnt working...can anyone 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)