8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal 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
11
.idea/BugMotion.iml
generated
Normal 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
6
.idea/misc.xml
generated
Normal 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
8
.idea/modules.xml
generated
Normal 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
6
.idea/vcs.xml
generated
Normal 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
35
main.py
Normal 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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user