That's ironically what I have been doing. Figured like you said, the code wont know whats attached, just sets the state... i knew that would work, but wasn't sure if there was a specific command to set a pin high or low.Consider a gpiozero LED to represent a pin you can write to or 'set'.i couldnt find how to manually set a specific pin to high or low.
Then see the basic LED example documentation.
https://gpiozero.readthedocs.io/en/stab ... s.html#led
The script doesn't know or care whether there is actually an LED connected.
There are underlying 'Digital Output' classes available if the oversimplification troubles you.
that being said, i also couldnt find how to read the state of a pin. would that be a similar situation where i would treat the pin as if a button where attached and read the state with if_pressed? I have a dip switch that has 6 switches which will be used to turn on and off "profiles" or tasks I want to have happen (ie check sensors that tell weather, check sensors that watch for water leaks/water pressure, check sensors that watch if a 120v line is hot or not)
the dip is fed by 3.3v and after the switch the line splits, one to power a led to visually tell me what profiles are on or off, and the other line runs to gpio pins, so when the pin is high the profile is active. I figure that is the same as a button being pressed as far as the code is concerned. would this be the right track to accomplish this, or do you have a better reccomendation?
Statistics: Posted by jfisher1991 — Thu Nov 21, 2024 9:26 pm