Last active
December 27, 2017 15:00
-
-
Save lyshie/68c6b5c1a3dc284cae5ec1bd9aef0e1e to your computer and use it in GitHub Desktop.
Micro:bit hangs at read_analog() - MicroPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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