'''
# Imports
from machine import Pin
import network
import time
# Network
ssid = "ssid"
password = "password"
# Email info
emailUser = "[email protected]"
emailPassword = "password"
emailSend = "address"
# PIR (motion sensor)
pir = Pin(27, Pin.IN)
# Connecting to wi-fi function
def connectWifi():
wlan = network.wlan(network.sta_if)
wlan.active(True)
if not wlan.isconnected():
if time.time() - start > timeout:
print("Failed to connect.")
return
time.sleep(0.5)
print("Connected to", ssid)
print("IP address:", wlan.ifconfig()[0])
print("Motion sensor active...")
connectWifi()
while True:
if pir.value():
print("Motion detected!")
else:
print("No motion.")
time.sleep(1)
connectWifi()
'''
from machine import Pin
import time
pir = Pin(27, Pin.IN)
while True:
print(pir.value())
time.sleep(1)