# Import necessary modules
from machine import SoftI2C, Pin, PWM
from utime import sleep, sleep_ms
import ssd1306_library
import urequests
import network
# Blynk Auth Token
BLYNK_AUTH = "Your_Blynk_Auth_Token"
# Connect to Blynk server
def connect_to_blynk():
global BLYNK_AUTH
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('Your_WiFi_SSID', 'Your_WiFi_Password')
while not wlan.isconnected():
pass
print("Connected to WiFi")
sleep(1)
print("Connecting to Blynk...")
sleep(1)
# Make a GET request to Blynk server to establish connection
urequests.get('http://blynk-cloud.com/' + BLYNK_AUTH + '/isHardwareConnected')
print("Connected to Blynk")
# Pin declaration for LEDs
green_led = Pin(25, Pin.OUT)
red_led = Pin(32, Pin.OUT)
# Initialize the PIR sensor on pin 34, LED on pin 12, and servo motor on pin 21
PIR_sensor = Pin(34, Pin.IN)
bar = PWM(Pin(23, Pin.OUT)) # PWM servo toll bar
bar.freq(50)
# Declare pins on OLED board
i2c_oled = SoftI2C(scl=Pin(2), sda=Pin(4))
# Define OLED basic parameters
oled_width = 140
oled_height = 70
# Called OLED with take from library
oled = ssd1306_library.SSD1306_I2C(oled_width, oled_height, i2c_oled)
# Move the servo motor to a specific angle
def move_servo(angle):