I am testing a one - note piano with a pushbutton on the microbit.
The digital reading is "1" in normal state, and "0" when the button is pressed. (signal goes to GND)
The the note is produced. So far so good.
My question:
The note keeps on sounding even after i release the button .
I expected that with the circuit open again, the reading would return to "1".
I am unsure if i should digital_write(1) myself or is something else wrong ?
Code: Select all
from microbit import *
import music
pinTest = pin1
while True:
sleep(2000)
x = pinTest.read_digital()
display.show(x)
if x == 0:
music.play('a')
sleep(1000)
pinTest.write_digital(1) # <<< WHY ?
display.show('?')
[\code]
Thanks,
Paul