Skip to content

Instantly share code, notes, and snippets.

@daniel-obrien
daniel-obrien / gpiotest.py
Created January 10, 2017 10:40 — forked from MrDMurray/gpiotest.py
STJLOL-GPIO_Test: Tests motors connected to GPIO 23,24 and 17,27
#For testing if a rover's motors are working.
#Runs each pair of motors forwards for 2 seconds, then backwards for 2 seonds.
#Full test tests about 14 seconds to cycle through.
#Godspeed.
import RPi.GPIO as GPIO #lets you use GPIO
from time import sleep #lets you use sleep(2) as a timer for the lights
GPIO.setmode(GPIO.BCM) #tells the program what labeling system to use
@daniel-obrien
daniel-obrien / light.py
Created January 10, 2017 10:40 — forked from MrDMurray/light.py
STJLOL-DMU Basic GPIO
#the setup
#Reminder: Do you have a resistor in series with your LED? If you don't you will kill the LED and damage the RPi.
import RPi.GPIO as GPIO #lets you use GPIO
from time import sleep #lets you use sleep(2) as a timer for the lights
GPIO.setmode(GPIO.BCM) #tells the program what labeling system to use. We'll use BCM
#because that's what it used on your blue cobbler on your breadboard.
GPIO.setup(17, GPIO.OUT) #tells the pi exactly what GPIO you'll be using
@daniel-obrien
daniel-obrien / gpioNB.py
Created January 10, 2017 10:40 — forked from MrDMurray/gpioNB.py
STJLOL GPIO essential code
#the setup
import RPi.GPIO as GPIO #lets you use GPIO
from time import sleep
GPIO.setmode(GPIO.BCM) #tells the program what labeling system to use. Use BCM.
GPIO.setup(23, GPIO.OUT) #tells the pi exactly what number pin you'll be using eg. 23
#the code
GPIO.output(23, GPIO.HIGH) #tells the pi to turn on this pin eg.23 turns on
sleep(1)
GPIO.output(23, GPIO.LOW) #tells the pi to turn off this pin eg.23 turns off
@daniel-obrien
daniel-obrien / deepakmotor.py
Created January 11, 2017 18:58 — forked from deepaksinghvi/deepakmotor.py
Program to control the DC motor using RaspberryPI and L298N Motor Controller
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
def forward(x):
GPIO.output(13, GPIO.HIGH)
sleep(x)