Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # blink_led.py
- # gpio test code for pcduino ( http://www.pcduino.com )
- #
- import gpio
- import time
- led_pin = "gpio6"
- led_pin2 = "gpio7"
- led_pin3 = "gpio8"
- #led_pin4 = "gpio9"
- pins = []
- pins.append(led_pin)
- pins.append(led_pin2)
- pins.append(led_pin3)
- #pins.append(led_pin4)
- pin_led_states = [
- [1, 0, -1], # A
- [0, 1, -1], # B
- [-1, 1, 0], # C
- [-1, 0, 1], # D
- [1, -1, 0], # E
- [0, -1, 1] # F
- ]
- def delay(ms):
- time.sleep(1.0*ms/1000)
- def set_pin(pin_index, pin_state):
- if pin_state == -1:
- gpio.pinMode(pins[pin_index], gpio.INPUT)
- else:
- gpio.pinMode(pins[pin_index], gpio.OUTPUT)
- gpio.digitalWrite(pins[pin_index], pin_state)
- def light_led(led_number):
- for pin_index, pin_state in enumerate(pin_led_states[led_number]):
- set_pin(pin_index, pin_state)
- def unsetpins():
- for x in range(0,len(pins)-1):
- set_pin(x, -1)
- unsetpins()
- x=0
- while True:
- #x = int(raw_input("Pin (0 to 5):"))
- if x<= 6:
- #light_led(x)
- light_led(x%6)
- delay(50)
- else:
- break
- x=x+1
- unsetpins()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement