Merge pull request #1 from Jordan-Fielding/Development

First Script
This commit is contained in:
Jordan-Fielding
2022-07-04 15:28:45 +10:00
committed by GitHub
6 changed files with 74 additions and 0 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

11
.idea/BugMotion.iml generated Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" project-jdk-name="Python 3.10 (Bugmotion)" project-jdk-type="Python SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/BugMotion.iml" filepath="$PROJECT_DIR$/.idea/BugMotion.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

35
main.py Normal file
View File

@@ -0,0 +1,35 @@
import RPi.GPIO as GPIO
import time
from picamera import PiCamera
camera = PiCamera()
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(22, GPIO.IN) #Read output from PIR motion sensor
GPIO.setup(27, GPIO.OUT) #LED output pin
i=GPIO.input(22)
try:
time.sleep(2) # to stabilize sensor
while True:
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d_%H:%M:%S')
if i==0: #When output from motion sensor is LOW
print ("No bugs detected",i)
GPIO.output(3, 0) #Turn OFF LED
time.sleep(0.1)
if i==1: #When output from motion sensor is HIGH
print ("bugs detected",i)
GPIO.output(3, 1) #Turn ON LED
camera.capture('image_Time_{}.jpg'.format(st))
os.system('libcamera-jpeg -o /home/pi/Pictures/image_Time_{}.jpg'.format(st))
camera.close() #Capture an Image
time.sleep(0.1)
except:
GPIO.cleanup()