forked from CamJam-EduKit/EduKit2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
59 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#Print Hello World! | ||
print "Hello World!" | ||
# Print Hello World! | ||
print("Hello World!") |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
# CamJam EduKit 2 - Sensors | ||
# Worksheet 3 - Light | ||
|
||
# Import Libraries | ||
import time | ||
import RPi.GPIO as GPIO | ||
|
||
# Set the GPIO Mode and set the pin to use for the | ||
# Set the GPIO Mode and set the pin to use for the | ||
GPIO.setmode(GPIO.BCM) | ||
GPIO.setwarnings(False) | ||
|
||
# A variable with the LDR reading pin number | ||
PINLDR = 27 | ||
|
||
def ReadLDR(): | ||
LDRCount = 0 # Sets the count to 0 | ||
GPIO.setup(PINLDR, GPIO.OUT) | ||
GPIO.output(PINLDR, GPIO.LOW) | ||
time.sleep(0.1) # Drains all charge from the capacitor | ||
|
||
GPIO.setup(PINLDR, GPIO.IN) # Sets the pin to be input | ||
# While the input pin reads ‘off’ or Low, count | ||
# While the input pin reads 'off' or Low, count | ||
while (GPIO.input(PINLDR) == GPIO.LOW): | ||
LDRCount += 1 # Add one to the counter | ||
return LDRCount | ||
while True: | ||
print ReadLDR() | ||
|
||
while True: | ||
print(ReadLDR()) | ||
time.sleep(1) # Wait for a second |
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
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