Pi2 problem with GPIO via Python - Raspberry Pi Forums
hello everyone, got pi2 diploma thesis , i'm trying make way through basic stuff blinking led. have correct wirings, , when use code, can turn led on , off:
can't seem via python. have updates installed, gpio v 0.5.11 , code is:
i'm running code sudo python led_blink.py , have tried many gpio ports, changing gpio.board layout , still nothing happens... help??
code: select all
sudo su cd /sys/class/gpio echo 4 > export cd gpio4 echo out > direction echo 1 > valuecode: select all
import rpi.gpio gpio import time gpio.setmode(gpio.bcm) gpio.setup(4, gpio.out) def blink(numtimes,speed): in range(0,numtimes): print "iteration " + str(i+1) gpio.output(4,true) time.sleep(speed) gpio.output(4,false) time.sleep(speed) print "done" gpio.cleanup() iterations = raw_input("enter total number of times blink: ") speed = raw_input("enter length of each blink(seconds): ") blink(int(iterations),float(speed))
first of need post code correct indentation (assuming you're using indentation...); may have programming errors don't show formatted now
, try simplified script first: switch on / off led, without bells , whistles have in there now.
, try simplified script first: switch on / off led, without bells , whistles have in there now.
raspberrypi
Comments
Post a Comment