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:

code: select all

sudo su cd /sys/class/gpio echo 4 > export cd gpio4 echo out > direction echo 1 > value
can't seem via python. have updates installed, gpio v 0.5.11 , code is:

code: 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))
i'm running code sudo python led_blink.py , have tried many gpio ports, changing gpio.board layout , still nothing happens... help??

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.


raspberrypi



Comments

Popular posts from this blog

How do I add a forum to my site? - Joomla! Forum - community, help and support

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

List Control