Im TRYING to learn Micropython and have had a basic issue thats have had me pulling my hair out on what seems a simple problem.
I'm learning from the official Micropython on Pico book, second edition. The scripts all seem to work initially on the first iteration of the program, LED's light and buttons are reacted to, but after that I don't get expected results.
In particular trying to get it to read the button in a reaction game. So much so that Ive had to electrically test things to make sure that there are no dodgy wires or connections on the breadboard.
Running the basic script below to see if it's even seeing a change of state returns no result initially, but when you press the button and release, it just outputs 1's. I either have to connect the other side of the button to GND and press it again or unplug the Pico from the USB and reconnect, then run again to get it to stop printing 1's.
So do these things latch high once the state has changed, and the book either omits to say that, or I missed it, or do I have a faulty pico?
Yes I've tried it on several pins with the same result. It seems to latch high unless you force it low with a connection or reset.
I'm learning from the official Micropython on Pico book, second edition. The scripts all seem to work initially on the first iteration of the program, LED's light and buttons are reacted to, but after that I don't get expected results.
In particular trying to get it to read the button in a reaction game. So much so that Ive had to electrically test things to make sure that there are no dodgy wires or connections on the breadboard.
Running the basic script below to see if it's even seeing a change of state returns no result initially, but when you press the button and release, it just outputs 1's. I either have to connect the other side of the button to GND and press it again or unplug the Pico from the USB and reconnect, then run again to get it to stop printing 1's.
So do these things latch high once the state has changed, and the book either omits to say that, or I missed it, or do I have a faulty pico?
Yes I've tried it on several pins with the same result. It seems to latch high unless you force it low with a connection or reset.
Code:
import machineimport timebutton = machine.Pin(14, machine.Pin.IN, machine.Pin.PULL_DOWN)while True: if button.value() == 1: print(button.value()) time.sleep(2)
Statistics: Posted by JustJodieMay — Sun Dec 29, 2024 3:40 pm — Replies 0 — Views 2