from machine import Pin, PWM
from utime import sleep
import time
import network
led = Pin(15, Pin.OUT)
pwm = PWM(Pin(23), freq=50, duty=0)
### WiFi Connecting
print("ESP Starting")
print('Connecting to WiFi', end='')
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('Wokwi-GUEST', '')
while not sta_if.isconnected():
print(".", end="")
time.sleep(0.1)
print(" Connected!")
led.on()
# MQTT Server Parameters
MQTT_CLIENT_ID = "2665719c-0eb5-4139-9dce-169cbf5ab969"
MQTT_BROKER = "XSzsDv1VSt4aCwvoC8D4oK8RzFZ4uceT"
MQTT_USER = ""
MQTT_PASSWORD = ""
MQTT_TOPIC = "wokwi-weather"
def set_angle(angle):
duty_cycle = int(((angle)/180*2+0.5)/20*1023)
pwm.duty(duty_cycle)
while True:
set_angle(90)
sleep(1)