# RESISTOR # | # | # Raspberry Pi GND PIN <--| # # RESISTOR = 470 R # import gpyo import time GPIO_PIN = 25 if __name__ == "__main__": gpyo.pin_function(GPIO_PIN, "output") gpyo.pin_state(GPIO_PIN, "high") time.sleep(1) gpyo.pin_state(GPIO_PIN, "low") time.sleep(1) gpyo.pin_state(GPIO_PIN, "high") time.sleep(1) gpyo.pin_state(GPIO_PIN, "low")
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # Tested Setup: # Raspberry Pi GPIO PIN -->| # | # | # SWITCH # | # | # Raspberry Pi GND PIN <--| import time import gpyo GPIO_PIN = 25 if __name__ == "__main__": gpyo.pin_function(GPIO_PIN, "input") gpyo.pin_resistor(GPIO_PIN, "pullup") for ctr in range(10): state = gpyo.pin_read(GPIO_PIN) print("State was %s" %( "high" if state else "low")) time.sleep(1)