Skip to content

Instantly share code, notes, and snippets.

@lyshie
Last active December 27, 2017 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyshie/68c6b5c1a3dc284cae5ec1bd9aef0e1e to your computer and use it in GitHub Desktop.
Save lyshie/68c6b5c1a3dc284cae5ec1bd9aef0e1e to your computer and use it in GitHub Desktop.
Micro:bit hangs at read_analog() - MicroPython
# Add your Python code here. E.g.
from microbit import *
uart.init(115200)
x = 0
pin0.write_analog(80)
sleep(1000)
while True:
x = x + 1
# enough time, OK!
sleep(20)
v = pin0.read_analog()
print("x = {}, analog = {}".format(x, v))
# Add your Python code here. E.g.
from microbit import *
uart.init(115200)
x = 0
pin0.write_analog(80)
sleep(1000)
while True:
x = x + 1
# there is not enough time to read analog, hangs at x = 177
sleep(10)
v = pin0.read_analog()
print("x = {}, analog = {}".format(x, v))
# Add your Python code here. E.g.
from microbit import *
uart.init(115200)
x = 0
pin0.write_analog(80)
sleep(1000)
while True:
x = x + 1
# hangs at x = 1000~1700
v = pin0.read_analog()
sleep(20)
print("x = {}, analog = {}".format(x, v))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment