Basic blinking LED on Raspberry Pi
Here's a simple python script for Raspberry Pi.
Step 1 - Install
sudo apt-get update
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
Step 2 - Python Script
This is the python script you will run.
#!/usr/env python
import RPi.GPIO as GPIO
import time
bcm = 25
board = 22
OUTPUT_PIN = board
DELAY_ON = 3
DELAY_OFF = 1
#Map the GPIO pins
if OUTPUT_PIN == board:
GPIO.setmode(GPIO.BOARD)
else:
GPIO.setmode(GPIO.BCM)
#GPIO takes two params(pin,state)
GPIO.setup(OUTPUT_PIN,GPIO.OUT)
i = 0
while i < 10:
i += 1
GPIO.output(OUTPUT_PIN,GPIO.HIGH)
time.sleep(DELAY_ON)
GPIO.output(OUTPUT_PIN,GPIO.LOW)
time.sleep(DELAY_OFF)
GPIO.output(OUTPUT_PIN,GPIO.LOW)
#After we open a connection, clean up after ourselves
GPIO.cleanup()