# IMPORT LIBRARIES
import machine
from utime import sleep
from ILI9341 import Display, color565
from xglcd_font import XglcdFont
from machine import DAC
from machine import Pin
adc_pot = machine.ADC(machine.Pin(26))
# PIN CONFIGURATIONS
# Configure the SPI pin
# Replace the x with SCK Pin x number here
sck = machine.Pin(18)
# Replace the y with MOSI Pin y number here
mosi = machine.Pin(23)
# Replace the z with MISO Pin z number here
miso = machine.Pin(19)
# spi configuration
spi = machine.SPI(1, baudrate=32000000, sck=sck, mosi=mosi, miso=miso)
# use spi with devices
# Replace the t with GPIO Pin t number here
rst = machine.Pin(2)
# Replace the u with GPIO Pin u number here
dc = machine.Pin(4)
# Replace the v with CS Pin v number here
cs = machine.Pin(5)
display = Display(spi, dc=dc, cs=cs, rst=rst)
arcadepix = XglcdFont('ArcadePix9x11.c', 9, 11)
# MAIN ROUTINE
def main():
while True:
#--
#ili9341_spi()
#debugging
adc_val = adc_pot.read()
print(adc_val)
readadc()
# SUBROUTINES
def readadc():
adc_val = adc_pot.read()
text = f"Potentiometer Value: {adc_val:.2f}"
display.draw_text(
x=15,
y=150,
text=text,
font=arcadepix,
color=color565(255, 0, 0),
background=color565(255, 255, 255),
landscape=False,
spacing=1,
)
sleep(1)
if __name__ == "__main__":
main()