Created
October 9, 2016 22:23
-
-
Save glennklockwood/e1a0bf94762c94864e4ffa4d3b185b3d to your computer and use it in GitHub Desktop.
Basic CD4017BE implementation for Raspberry Pi
This file contains hidden or 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
#!/usr/bin/env python | |
import RPi.GPIO as GPIO | |
input_pin = 14 | |
output_pins = [22, 17, 5, 6, 13, 12, 25, 24, 27, 23] | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(input_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | |
for pin in output_pins: | |
GPIO.setup(pin, GPIO.OUT) | |
i = 0 | |
active_pin = output_pins[0] | |
while True: | |
GPIO.wait_for_edge(input_pin, GPIO.FALLING) | |
GPIO.output(active_pin, GPIO.LOW) | |
active_pin = output_pins[i % len(output_pins)] | |
GPIO.output(active_pin, GPIO.HIGH) | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment