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
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) |
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
#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 |
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
#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 |
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
#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 |