| |
| python:micropython:es [2023/08/20 09:45] – [Modifier - Pane] phil | python:micropython:es [Date inconnue] (Version actuelle) – supprimée - modification externe (Date inconnue) 127.0.0.1 |
|---|
| |
| |
| ===== MicroPython - Entrées, Sorties (GPIO) ===== | |
| {{ :micropython:logomicropython.png?nolink&120|}} | |
| |
| |
| * **Ressources** | |
| * <html><a href="https://micropython.org/" target="_blank">MicroPython.org</a></html> | |
| * <html><a href="https://docs.micropython.org/en/latest/index.html#" target="_blank">MicroPython documentation</a></html> | |
| * <html><a href="https://thonny.org/" target="_blank">IDE Thonny</a></html> | |
| |
| * **Lectures connexes** | |
| * <html><a href="https://randomnerdtutorials.com/esp32-esp8266-digital-inputs-digital-outputs-micropython/" target="_blank">ESP32/ESP8266 Digital Inputs and Digital Outputs with MicroPython</a></html> | |
| * <html><a href="https://randomnerdtutorials.com/micropython-gpios-esp32-esp8266/" target="_blank">MicroPython with ESP32 and ESP8266: Interacting with GPIOs</a></html> | |
| * <html><a href="https://randomnerdtutorials.com/esp32-esp8266-pwm-micropython/" target="_blank">ESP32/ESP8266 PWM with MicroPython – Dim LED</a></html> | |
| * <html><a href="https://randomnerdtutorials.com/esp32-esp8266-analog-readings-micropython/" target="_blank">ESP32/ESP8266 Analog Readings with MicroPython</a></html> | |
| * <html><a href="https://randomnerdtutorials.com/micropython-interrupts-esp32-esp8266/" target="_blank">MicroPython: Interrupts with ESP32 and ESP8266</a></html> | |
| |
| |
| |
| |
| |
| |
| |
| {{ :materiels:capteurs:potentiometre.png?nolink&80|Potentiomètre}} | |
| ==== 3. Entrées analogiques ==== | |
| * **Ressource** | |
| * <html><a href="https://docs.micropython.org/en/latest/rp2/quickref.html#pins-and-gpio" target="_blank"><strong>Quick reference for the RP2</strong>, Pins and GPIO </a>sur Micropython.org.</html>, potentiomètre 10kOhm. | |
| |
| === 3.1 Présentation === | |
| * **Ressource** | |
| * <html><a href="https://docs.micropython.org/en/latest/rp2/quickref.html#pins-and-gpio" target="_blank"><strong>Quick reference for the RP2</strong>, Pins and GPIO </a>sur Micropython.org.</html>, potentiomètre 10kOhm. | |
| {{ :materiels:capteurs:environnement:code.png?nolink|}} | |
| === 3.2 Exemples de code === | |
| <tabs> | |
| * [[#tab-pico_4|RPi Pico]] | |
| * [[#tab-esp32_4|ESP32]] | |
| |
| <pane id="tab-pico_4"> | |
| | |
| </pane> | |
| |
| <pane id="tab-esp32_4"> | |
| * **Ressource** | |
| * <html><a href="https://docs.micropython.org/en/latest/esp32/quickref.html#adc-analog-to-digital-conversion" target="_blank">ADC (analog to digital conversion)</a></html> sur Micropython.org. | |
| //Exemple de code pour un **ESP32 Feather Huzzah**// | |
| <code python *.py> | |
| # ADC accessibles en Python sur la carte ESP32 Feather Huzzah : | |
| # ADC:GPIO | |
| # A2 : 34 | |
| # A3 : 39 | |
| # A4 : 36 | |
| # A7 : 32 | |
| # A9 : 33 | |
| |
| from machine import ADC, Pin | |
| |
| # Le potentiomètre 10kOhm est connecté à l'entrée analogique A2 de l'ESP32. | |
| # Configuration | |
| adc = ADC(Pin(34)) | |
| # Sur une entrée analogique, la tension doit | |
| # être comprise entre 0 - 3,3V (3,6V max !) | |
| adc.atten(ADC.ATTN_11DB) # voir doc | |
| # Mesure | |
| value = adc.read() | |
| |
| print(value) # affichage dans la console | |
| </code> | |
| </pane> | |
| </tabs> | |
| |
| |