Permalink
Browse files

All sorts of changes

  • Loading branch information...
1 parent 8f2a1ee commit 31a43f38e8e8c4b1549ace9f0b746438d63210c5 @videoman committed Mar 4, 2013
Showing with 88 additions and 13 deletions.
  1. +15 −1 LED_Fun1.py
  2. +15 −1 LED_Fun2.py
  3. +16 −1 LED_Fun3.py
  4. +4 −0 LED_Fun4-function.py
  5. +4 −0 LED_Fun5.py
  6. +4 −0 LED_Fun6-sequ.py
  7. +4 −0 LED_Fun7-RGB.py
  8. +14 −10 LED_Fun8-LightSensor.py
  9. +2 −0 README.txt
  10. 0 Relay_Fun3.py
  11. +1 −0 Stepper_Motor_Feed.py
  12. +1 −0 Stepper_Motor_test.py
  13. +8 −0 Tempature_Sensor.py
View
@@ -3,22 +3,36 @@
# Hack Factory Raspberry Pi Class.
# David M. N. Bryan, dave@drstrangelove.net
#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
+#
+# I am a comment in the code!
+# This does not get interperted or used in any way!
+# Comments are very useful to make things readable...
+#
# import the Raspberry Pi GPIO Library
import RPi.GPIO as GPIO
# Define OUTPUT Pins on RPI
+# Plug a 560ohm reisitor from each of the defined PINs into the + (long leg) side of an LED.
+# Now connect the short leg to the ground rail.
GPIORed_PIN=27
GPIOGreen_PIN=17
GPIOBlue_PIN=22
-# Set the pins to OUTPUTS
+# set the GPIO Pinout to the BCM chip
GPIO.setmode(GPIO.BCM)
+# Set the pins to OUTPUTS
GPIO.setup(GPIORed_PIN, GPIO.OUT)
GPIO.setup(GPIOGreen_PIN, GPIO.OUT)
GPIO.setup(GPIOBlue_PIN, GPIO.OUT)
+# Turn all of the lights on
while True:
GPIO.output(GPIORed_PIN, True)
GPIO.output(GPIOGreen_PIN, True)
GPIO.output(GPIOBlue_PIN, True)
+
+# That's it. All your lights should go on.
View
@@ -3,6 +3,10 @@
# Hack Factory Raspberry Pi Class.
# David M. N. Bryan, dave@drstrangelove.net
#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
+#
#import the Raspberry Pi GPIO Library
import RPi.GPIO as GPIO
@@ -12,21 +16,31 @@
GPIORed_PIN=27
GPIOGreen_PIN=17
GPIOBlue_PIN=22
+# This is the delay that we are going to insert, in this case 1 second.
SLEEP_TIME=1
-# Set the pins to OUTPUTS
+# Set our GPIO library up...
GPIO.setmode(GPIO.BCM)
+# Set the pins to OUTPUTS
GPIO.setup(GPIORed_PIN, GPIO.OUT)
GPIO.setup(GPIOGreen_PIN, GPIO.OUT)
GPIO.setup(GPIOBlue_PIN, GPIO.OUT)
+# Enter into a loop...
while True:
+ #Turn on each led...
GPIO.output(GPIORed_PIN, True)
GPIO.output(GPIOGreen_PIN, True)
GPIO.output(GPIOBlue_PIN, True)
+ # Wait for "SLEEP_TIME" seconds before we do the next action.
time.sleep(SLEEP_TIME)
+ # Turn off all the LEDs.
GPIO.output(GPIORed_PIN, False)
GPIO.output(GPIOGreen_PIN, False)
GPIO.output(GPIOBlue_PIN, False)
+ # Sleep for a period...
time.sleep(SLEEP_TIME)
+
+
+# Do this until we stop the program.
View
@@ -3,6 +3,10 @@
# Hack Factory Raspberry Pi Class.
# David M. N. Bryan, dave@drstrangelove.net
#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
+#
#import the Raspberry Pi GPIO Library
import RPi.GPIO as GPIO
@@ -14,9 +18,11 @@
GPIOBlue_PIN=22
# How about some input please?
+# This will define what pin we want to use for a button input...
BUTTON1_PIN=24
-# How long do we sleep between cycles
+# How long do we sleep between cycles, we can set this to .25 for 1/4
+# of a second, but you may not be able to percive it thank to POV.
SLEEP_TIME=1
# Set the pins on the GPIO up.
@@ -30,13 +36,22 @@
#Setup the INPUTs (Buttons)
GPIO.setup(BUTTON1_PIN, GPIO.IN)
+# Do this thing that I say until someone kills this loop...
while True:
+ # Has the button been pushed?
if ( GPIO.input(BUTTON1_PIN) == True ):
+ # Looks like it was pushed, and while it's still pushed, lets
+ # make some pretty blinks...
+ # All on!
GPIO.output(GPIORed_PIN, True)
GPIO.output(GPIOGreen_PIN, True)
GPIO.output(GPIOBlue_PIN, True)
+ # ZZzzzzzzz....
time.sleep(SLEEP_TIME)
+ # All off!
GPIO.output(GPIORed_PIN, False)
GPIO.output(GPIOGreen_PIN, False)
GPIO.output(GPIOBlue_PIN, False)
+ # Sleeepy time..zzzz
time.sleep(SLEEP_TIME)
+
View
@@ -3,6 +3,10 @@
# Hack Factory Raspberry Pi Class.
# David M. N. Bryan, dave@drstrangelove.net
#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
+#
#import the Raspberry Pi GPIO Library
import RPi.GPIO as GPIO
View
@@ -3,6 +3,10 @@
# Hack Factory Raspberry Pi Class.
# David M. N. Bryan, dave@drstrangelove.net
#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
+#
#import the Raspberry Pi GPIO Library
import RPi.GPIO as GPIO
View
@@ -3,6 +3,10 @@
# Hack Factory Raspberry Pi Class.
# David M. N. Bryan, dave@drstrangelove.net
#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
+#
#import the Raspberry Pi GPIO Library
import RPi.GPIO as GPIO
View
@@ -3,6 +3,10 @@
# Hack Factory Raspberry Pi Class.
# David M. N. Bryan, dave@drstrangelove.net
#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
+#
#import the Raspberry Pi GPIO Library
import RPi.GPIO as GPIO
View
@@ -6,6 +6,10 @@
# Info on how to wire up the Light sensor can be found at:
# http://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi/basic-photocell-reading
#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
+#
#import the Raspberry Pi GPIO Library
import RPi.GPIO as GPIO, time, os
@@ -85,16 +89,16 @@ def RCtime (RCpin):
light_level=RCtime(18)
if ( light_level >= 200 ):
- blink_all_leds(0.25)
-# blink_led('RED',0.5 )
-# blink_led('GREEN',0.5 )
-# blink_led('BLUE',0.5 )
+# blink_all_leds(0.25)
+ blink_led('RED',0.5 )
+ blink_led('GREEN',0.5 )
+ blink_led('BLUE',0.5 )
- if ( GPIO.input(BUTTON1_PIN) == True ):
- blink_led('RED',0.5)
+ #if ( GPIO.input(BUTTON1_PIN) == True ):
+ #blink_led('RED',0.5)
- if ( GPIO.input(BUTTON2_PIN) == True ):
- blink_led('GREEN',0.5)
+ #if ( GPIO.input(BUTTON2_PIN) == True ):
+ #blink_led('GREEN',0.5)
- if ( GPIO.input(BUTTON3_PIN) == True ):
- blink_led('BLUE',0.5)
+ #if ( GPIO.input(BUTTON3_PIN) == True ):
+ #blink_led('BLUE',0.5)
View
@@ -2,6 +2,8 @@ These are example python programs for working with GPIO on the Raspberry Pi rele
This is for the Raspberry Pi class that we teach at The Hack Factory, http://tcmaker.org.
+If you want the presentation that goes along with this, please feel free to email me and I can send along what I've been using to teach the classes.
+
-David Bryan
dave at drstrangelove dot net
View
0 Relay_Fun3.py 100644 → 100755
No changes.
View
@@ -1,6 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
+
import RPi.GPIO as GPIO
import time
import sys
View
@@ -1,4 +1,5 @@
#!/usr/bin/python
+# This code is in need of a clean up...
# -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
View
@@ -1,3 +1,11 @@
+#!/usr/bin/env python
+#
+# Hack Factory Raspberry Pi Class.
+# David M. N. Bryan, dave@drstrangelove.net
+#
+# This is licend under creative commons license:
+# http://creativecommons.org/licenses/by-nc-sa/3.0/
+# Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
#
# More info on wiring and what not can be found at:
# http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

0 comments on commit 31a43f3

Please sign in to comment.