import machine
import time
potentiometer_value = 0
potentiometer_pin = machine.ADC(26) # Change to the correct ADC pin
# Function to read the potentiometer value from the custom chip (slider-controlled)
def read_potentiometer_value():
return potentiometer_value # Return the manually set value (from slider)
# Function to simulate the potentiometer value change (from slider)
def set_potentiometer_value(value):
global potentiometer_value
if 0 <= value <= 1023:
potentiometer_value = value # Set value within valid range (0-1023)
else:
print("Invalid value! Must be between 0 and 1023.")
# Main program to simulate reading values and adjusting via a slider
while True:
# Read the potentiometer value (you can simulate this via the slider in Wokwi)
value = read_potentiometer_value()
# Print the current potentiometer value to the serial monitor
print("Potentiometer Value:", value)
# Simulate setting a new potentiometer value (you can change this value manually during simulation)
new_value = int(input("Enter new potentiometer value (0-1023): "))
set_potentiometer_value(new_value)
time.sleep(1) # Delay for readability