Saturday, April 16, 2016

Raspberry Pi 2 B - BlinkLed


//first program one led
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
for x in range(0,3):
    GPIO.output(7,True)
    time.sleep(1)
    GPIO.output(7,False)
    time.sleep(1)
GPIO.cleanup()


//second program three leds
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
for x in range(0,10):
    GPIO.output(7,True)
    time.sleep(.5)
    GPIO.output(7,False)
    GPIO.output(11,True)
    time.sleep(.5)
    GPIO.output(11,False)
    GPIO.output(13,True)
    time.sleep(.5)
    GPIO.output(13,False)
GPIO.cleanup()

from here

//Note
If you want to always run IDLE with root privs then simply edit the desktop link entry in ~/Desktop and change the following line:
Exec=/usr/bin/idle
to
Exec=sudo /usr/bin/idle

from here

//Repair RPi.GPIO

sudo apt-get update
sudo apt-get install python-pip
sudo pip install -U RPi.GPIO
from here

Filed Under :

0 comments for "Raspberry Pi 2 B - BlinkLed"

Post a Comment

background