#programme affichage valeur potentiomètre sur ecran Oled
from machine import Pin, ADC, I2C
from time import sleep
import ssd1306
potar = ADC(Pin(35)) # Initialise l'objet potar correspondant à notre potentiomètre sur la broche 4 sur la broche 34
potar.atten(ADC.ATTN_11DB) # étalonnage (étendue totale sur ESP32 : 3.3V)
oled_width = 128
oled_height = 64
i2c = I2C(0, scl=Pin(22), sda=Pin(21)) #affectation des PIn du Bus numérique I2C (ecran Oled fonctionne avec bus I2C)
ecran_oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) # Initialise l'ecran Oled
while True:#Boucle Principale du programmee
valeurPotar = potar.read()
print("Valeur potar =", valeurPotar)
ecran_oled.fill(0) #clear l'ecran
ecran_oled.text(str(valeurPotar), 10, 10) #affichage valeurPotar en position x=10,y=10
ecran_oled.show()
sleep(0.1)