Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5011

MicroPython • PULL_UP PULL_DOWN State is back to front?

$
0
0
Hi
I am using the Wokwi emulator, so I'm not sure if it's the emulator, my electronics, my code or my understanding, but the following code and wiring start low and pulls high, which is incorrect for a Pin.PULL_DOWN configuration.

Code:

class Pedestrian_Button(Pin):    # child class inherits the parent 'Pin' class    def __init__(self, pin, debug=False):        super().__init__(pin, Pin.IN, Pin.PULL_DOWN)   # <--- Only works when configured as PULL_DOWN ???        self.button_state        self.__debug = debug        self.__pin = pin    @property    def button_state(self):        print(self.value())        return self.value()
For this behaviour, shouldn't I be configuring the resistor as Pin.Pull_UP?
prototype_model.png
Wokwi project: https://wokwi.com/projects/419938862117728257

Statistics: Posted by benpaddlejones — Fri Jan 24, 2025 2:16 am



Viewing all articles
Browse latest Browse all 5011

Trending Articles