Advertisement
tdrobotica

Prueba funcionamiento Nivel J

Jan 4th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. from machine import ADC
  2. from machine import Pin
  3. import neopixel
  4. import time
  5.  
  6. #Pulsador
  7. puls1 = Pin(14, Pin.IN)
  8. puls2 = Pin(15, Pin.IN)
  9.  
  10. #Entradas analógicas
  11. pot = ADC(Pin(32))
  12. joyx = ADC(Pin(39))
  13. joyy = ADC(Pin(36))
  14.  
  15. pot.atten(ADC.ATTN_11DB)
  16. joyx.atten(ADC.ATTN_11DB)
  17. joyy.atten(ADC.ATTN_11DB)
  18.  
  19. #LED
  20. ain1 = Pin(12, Pin.OUT)
  21. ain2 = Pin(13, Pin.OUT)
  22. bin1 = Pin(18, Pin.OUT)
  23. bin2 = Pin(19, Pin.OUT)
  24.  
  25. #LED RGB
  26. ledRGB = neopixel.NeoPixel(Pin(4, Pin.OUT), 3)
  27.  
  28. while True:
  29.     if puls1.value() == 1:
  30.         ledRGB[0] = (0x22, 0x00, 0x00)
  31.     elif puls1.value() == 0:
  32.         ledRGB[0] = (0x00, 0x22, 0x00)
  33.        
  34.     if puls2.value() == 1:
  35.         ledRGB[2] = (0x00, 0x00, 0x0FF)
  36.     elif puls2.value() == 0:
  37.         ledRGB[2] = (0x00, 0x22, 0x00)
  38.    
  39.     ledRGB.write()
  40.    
  41.     if pot.read() > 2000:
  42.         ledRGB[1] = (0x22, 0x22, 0x22)
  43.     else:
  44.         ledRGB[1] = (0x00, 0x22, 0x00)
  45.        
  46.     if joyx.read() > 2000:
  47.         ain1.on()
  48.         ain2.on()
  49.     else:
  50.         ain1.off()
  51.         ain2.off()
  52.        
  53.     if joyy.read() > 2000:
  54.         bin1.on()
  55.         bin2.on()
  56.     else:
  57.         bin1.off()
  58.         bin2.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement