Code syntax error
Posted: Tue Jan 31, 2017 8:08 pm
Hello everyone,
I'm working on a pedometer feature for my micro:bit and I'm trying to upload the following code below. However, after it's uplodaed, this error message appears:
line 7 syntax error - invalid syntax
I can't find the correct syntax that would make the code work. Could somebody help me on this one? Thanks!
from microbit import *
steps = 0
while True:
#display.clear()
agx = accelerometer.get_x()
if agx > 300:
steps += 1
sleep(100)
if steps > 0:
display.set_pixel(0,0,9)
if steps > 10:
display.set_pixel(1,0,9)
if steps > 20:
display.set_pixel(2,0,9)
if steps > 30:
display.set_pixel(3,0,9)
if steps > 40:
display.set_pixel(4,0,9)
if steps > 50:
display.set_pixel(0,1,9)
if steps > 60:
display.set_pixel(1,1,9)
if steps > 70:
display.set_pixel(2,1,9)
if steps > 80:
display.set_pixel(3,1,9)
if steps > 90:
display.set_pixel(4,1,9)
I'm working on a pedometer feature for my micro:bit and I'm trying to upload the following code below. However, after it's uplodaed, this error message appears:
line 7 syntax error - invalid syntax
I can't find the correct syntax that would make the code work. Could somebody help me on this one? Thanks!
from microbit import *
steps = 0
while True:
#display.clear()
agx = accelerometer.get_x()
if agx > 300:
steps += 1
sleep(100)
if steps > 0:
display.set_pixel(0,0,9)
if steps > 10:
display.set_pixel(1,0,9)
if steps > 20:
display.set_pixel(2,0,9)
if steps > 30:
display.set_pixel(3,0,9)
if steps > 40:
display.set_pixel(4,0,9)
if steps > 50:
display.set_pixel(0,1,9)
if steps > 60:
display.set_pixel(1,1,9)
if steps > 70:
display.set_pixel(2,1,9)
if steps > 80:
display.set_pixel(3,1,9)
if steps > 90:
display.set_pixel(4,1,9)