Skip to content

Instantly share code, notes, and snippets.

@nunthaphong127
Created October 29, 2020 09:34
Show Gist options
  • Save nunthaphong127/78babe58cb4ae742ad38814629b9e827 to your computer and use it in GitHub Desktop.
Save nunthaphong127/78babe58cb4ae742ad38814629b9e827 to your computer and use it in GitHub Desktop.
Nunthaphong127
import RPi.GPIO as GPIO
import time
import requests
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(26,GPIO.IN)
GPIO.setup(17,GPIO.OUT)
GPIO.setup(27,GPIO.OUT)
appid = "NTP"
gearkey = "3k8Xi6hLwcAe4ep"
gearsecret = "AmimfxqyaK7mAtjxpEVBnjIZ0"
while True:
i=GPIO.input(26)
if i==0:
print("No intruders",i)
GPIO.output(17,GPIO.LOW)
GPIO.output(27,GPIO.LOW)
time.sleep(0.3)
elif i==1:
print("Intruder detected",i)
GPIO.output(17,GPIO.HIGH)
GPIO.output(27,GPIO.LOW)
time.sleep(0.3)
GPIO.output(17,GPIO.LOW)
GPIO.output(27,GPIO.HIGH)
time.sleep(0.3)
GPIO.output(17,GPIO.HIGH)
GPIO.output(27,GPIO.LOW)
time.sleep(0.3)
url = 'https://notify-api.line.me/api/notify'
token = 'zbRPriCKlSAtqWeqXyCJXOMVz3qy7GHiTPMVUULc4ru'
headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer '+token}
msg = 'คนทีเดินผ่านประตู'
r = requests.post(url, headers=headers, data = {'message':msg})
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment