from machine import Pin, ADC, I2C
from time import sleep
import lcd_api
import i2c_lcd
# Define the I2C pins and initialize the I2C interface
i2c = I2C(1, scl=Pin(22), sda=Pin(21), freq=400000)
# Initialize the LCD
lcd = i2c_lcd.I2cLcd(i2c, 0x27, 4, 20)
# Define the ADF8317 pin
rf_output_pin = ADC(Pin(36)) # ADC1 channel 0 is GPIO36
# wala pa pong nakalagay
def setup():
# Initialize the LCD
lcd.putstr("RF Detector\n")
def loop():
while True:
# Read the analog input from the RF output pin and convert to voltage
val = rf_output_pin.read()
rf_output = (val * 3.3) / 4095.0 # Convert the analog value to voltage (assuming 3.3V supply)
# Clear the LCD display for new content
lcd.clear()
# Display the RF output on the LCD
lcd.putstr("RF Output:\n")
lcd.putstr("{:.2f} V".format(rf_output))
# Print details to the serial monitor for debugging
print("RF Output: {:.2f} V".format(rf_output))
sleep(0.5) # Add a small delay for stability
# Run the setup function
setup()
# Start the loop
loop()Loading
arduino-nano-esp32
arduino-nano-esp32