The following code works just fine:
# Add your Python code here. E.g.
from microbit import *
score = 0
display.show(str(score))
while True:
if accelerometer.was_gesture('face down'):
score += 1
if score < 10:
display.show(score)
else:
display.scroll(score)
continue
'''But when I try to replace was_gesture('face down') with get_Z i get an error:'''
# Add your Python code here. E.g.
from microbit import *
score = 0
display.show(str(score))
z = accelerometer.get_z()
while True:
if z < accelerometer.get_z(-500)
score += 1
if score < 10:
display.show(score)
else:
display.scroll(score)
continue
I get an error? But why? I just want to get the microbit to count every time I move the device below a certain point?
You've missed a colon at the end of this line:
if z < accelerometer.get_z(-500)
Also, the get_z()
method doesn't take any arguments:
https://microbit-micropython.readthedocs.io/en/latest/accelerometer.html#microbit.accelerometer.get_z