tdrobotica

Proyecto potenciometro

Dec 29th, 2021 (edited)
1,900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. #importar librerias
  2. from machine import Pin, ADC
  3. from time import sleep
  4.  
  5. def main():
  6.     #definir al pin 32 como entrada analoga
  7.     pot = ADC(Pin(32))
  8.     pot.atten(ADC.ATTN_11DB)
  9.    
  10.     while(1):
  11.         #alternar el valor del led
  12.         pot_value = pot.read()
  13.         print('Pot: ' + str(pot_value))
  14.         #tiempo de espera
  15.         sleep(0.5)
  16.  
  17. #ruta de ejecucion
  18. if __name__ == "__main__":
  19.     main()
Add Comment
Please, Sign In to add comment