from machine import Pin,ADC,PWM
from mfrc522 import MFRC522
from i2c_lcd import I2cLcd
from machine import SPI
from machine import SoftI2C
from time import sleep
import dht11
X=PWM(Pin(27,mode=Pin.OUT)) #servo motor
X.freq(50)
d=dht.DHT22(Pin(14)) #dht11
lcd_Addr=0x27
i2c=I2C(scl=Pin(23,Pin.OUT,Pin.PULL_UP),
sda=Pin(21,Pin.OUT,Pin.PULL_UP),freq=400000)
lcd = I2cLcd(i2c,lcd_Addr,2,16)
red =Pin(14,Pin.OUT)
grn=Pin(13,Pin.OUT)
spi=SPI(2,baudrate=2500000,polarity=0,phase=0)
spi.init()
rdr= MFRC522(spi=spi,gpioRst=4,gpioCs=5)
print("Place Card")
lcd.clear()
lcd.move_to(0,0)
lcd.putstr("Scan RFID")
h=-1
t=-1
while True:
(stat,tag_type)=rdr.request(rdr.REQIDL)
if stat==rdr.OK:
(stat,raw_uid)=rdr.anticoll()
if stat==rdr.OK:
lcd.clear()
lcd.move_to(0,0)
lcd.putstr("RFID:")
card_id="0x%02x%02x%02x%02x" %(raw_uid[0],
raw_uid[1],raw_uid[2],raw_uid[3])
print("UID:",card_id)
lcd.move_to(0,1)
if card_id =="0x57c07f5a":
grn.value(True)
red.value(False)
X.duty(90)
time.sleep(1)
lcd.putstr("Access Granted")
def
else:
grn.value(False)
red.value(True)
lcd.putstr("Access Denied!")
for i in range(10):
testLcd(i)
sleep_ms(500)
def testLcd(num):
lcd.move_to(0,0)
lcd.putstr('Sarfaraj')
lcd.move_to(0,1)
lcd.putstr("ECE663"+" "+str(num))
while True:
for i in range(10):
testLcd(i)
sleep_ms(500)
led =Pin(5,Pin.OUT)
sensor=dht.DHT22(Pin(14))
I2C_ADDR=0x27
totalRows=2
totalColumns=16
i2c=softI2C(scl=Pin(22),sda=Pin(21),freq=10000)
lcd=I2cLcd(i2c,I2C_ADDR,totalRows,totalColumns)
lcd.putstr("Hello")
h=-1
t=-1
while True:
sensor.measure()
t=sensor.temprature()
if h!=sensor.humidity():
h=sensor.humidity()
lcd.clear()
lcd.putstr("the humidity:")
lcd.putstr(str(h))
if t>40:
led.on()
else:
led.off()
time.sleep(1)
lcd.clear()
# X=PWM(Pin(27,mode=Pin.OUT))
# X.freq(50)
# lcd_Addr=0x20
# i2c=I2C(scl=Pin(23,Pin.OUT,Pin.PULL_UP),
# sda=Pin(21,Pin.OUT,Pin.PULL_UP),freq=400000)
# lcd = I2cLcd(i2c,lcd_Addr,2,16)
# red =Pin(14,Pin.OUT)
# grn=Pin(13,Pin.OUT)
# spi=SPI(2,baudrate=2500000,polarity=0,phase=0)
# spi.init()
# rdr= MFRC522(spi=spi,gpioRst=4,gpioCs=5)
# print("Place Card")
# lcd.clear()
# lcd.move_to(0,0)
# lcd.putstr("Scan RFID")
# while True:
# (stat,tag_type)=rdr.request(rdr.REQIDL)
# if stat==rdr.OK:
# (stat,raw_uid)=rdr.anticoll()
# if stat==rdr.OK:
# lcd.clear()
# lcd.move_to(0,0)
# lcd.putstr("RFID:")
# card_id="0x%02x%02x%02x%02x" %(raw_uid[0],
# raw_uid[1],raw_uid[2],raw_uid[3])
# print("UID:",card_id)
# lcd.move_to(0,1)
# if card_id =="0x57c07f5a":
# grn.value(True)
# red.value(False)
# lcd.putstr("Access Granted")
# else:
# grn.value(False)
# red.value(True)
# lcd.putstr("Access Denied!")
# pyproject.toml
# [build-system]
# requires = ["setuptools>=61.0.0", "wheel"]
# build-backend = "setuptools.build_meta"
# [project]
# name = "micropython-servo"
# version = "1.0.1"
# description = "Use rc servos with PWM in micropython in a tidy way"
# readme = "README.md"
# authors = [{ name = "redoxcode", email = "[email protected]" }]
# license = { file = "LICENSE" }
# classifiers = [
# "License :: OSI Approved :: MIT License",
# "Programming Language :: Python :: Implementation :: MicroPython"
# ]
# keywords = ["servo","PWM"]
# dependencies = []
# [project.optional-dependencies]
# dev = []
# [project.urls]
# Homepage = "https://github.com/redoxcode/micropython-servo"