Last active
September 27, 2015 04:14
-
-
Save fnishio/76e94f53a8cc379f4f52 to your computer and use it in GitHub Desktop.
Shell & python scripts to blink LED on Raspberry Pi GPIO. RPi.GPIO and WiringPi2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import RPi.GPIO as GPIO | |
import time | |
LEDPIN = 25 | |
#GPIO.setwarnings(False) # Suppress warnings | |
#GPIO.setmode( GPIO.BOARD ) | |
GPIO.setmode( GPIO.BCM ) | |
GPIO.setup( LEDPIN, GPIO.OUT ) | |
c = 0 | |
while c < 5: | |
GPIO.output( LEDPIN, True ) | |
time.sleep( 1.0 ) | |
GPIO.output( LEDPIN, False ) | |
time.sleep( 1.0 ) | |
c = c + 1 | |
GPIO.output (LEDPIN, GPIO.LOW) | |
GPIO.cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# use GPIO25 | |
echo 25 > /sys/class/gpio/export | |
sleep 1 | |
# use GPIO25 for output | |
echo out > /sys/class/gpio/gpio25/direction | |
# set HIGH | |
echo 1 > /sys/class/gpio/gpio25/value | |
sleep 1 | |
# set LOW | |
echo 0 > /sys/class/gpio/gpio25/value | |
# close GPIO25 | |
echo 25 > /sys/class/gpio/unexport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import wiringpi2 as wp | |
import time | |
LED_PIN = 25 | |
wp.wiringPiSetupGpio() | |
wp.pinMode(25, wp.GPIO.OUTPUT) | |
for c in range(0, 5): | |
wp.digitalWrite(25, wp.GPIO.HIGH) | |
time.sleep(0.5) | |
wp.digitalWrite(25, wp.GPIO.LOW) | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment