python:micropython:es

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

python:micropython:es [2023/08/20 07:42] – [MicroPython - Entrées, Sorties (GPIO)] philpython:micropython:es [Date inconnue] (Version actuelle) – supprimée - modification externe (Date inconnue) 127.0.0.1
Ligne 1: Ligne 1:
-[[:python:micropython:accueil|{{ :iconemaison.jpg?nolink&30|Sommaire MicroPython, CircuitPython}}]] 
- 
-===== MicroPython - Entrées, Sorties (GPIO) ===== 
-{{ :micropython:logomicropython.png?nolink&120|}} 
- 
-[Mise à jour le : 1/6/2023] <html><span style="color:red">En cours de rédaction</span></html> 
- 
-  * **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> 
- 
- 
-==== 2. Entrées, sorties numériques ==== 
- 
-{{ :python:micropython:materiel:led.jpg?nolink&100|LED}} 
-{{ :python:micropython:pmod_btn_25707.png?nolink&90|Digilent Pmod BTN: 4 User Pushbuttons}} 
- 
-=== 2.3 Interruption === 
-  * **Matériel** : [[arduino:uc:esp32|ESP32 Feather Huzzah]] ou [[python:micropython:raspypico2040|Raspberry Pi Pico]], <html><a href="https://fr.rs-online.com/web/p/modules-de-developpement-d-interface-homme-machine-ihm/1368059/" target="_blank" title="Distributeur">Digilent Pmod BTN: 4 User Pushbuttons</a></html> <html><a href="https://reference.digilentinc.com/_media/reference/pmod/pmodbtn/pmodbtn_sch.pdf" target="_blank">[Schéma]</a></html> 
- 
-== 2.3.2 Configuration == 
-La configuration en entrée de la broche destinée à recevoir un évènement est identique à celle du paragraphe précédent. \\ \\ 
- 
-== 2.3.3 Evènement et gestionnaire d'évènement == 
-Un évènement est attaché à un gestionnaire (service d'interruption) . \\ \\ 
- 
-{{ :materiels:capteurs:environnement:code.png?nolink|}} 
-== 2.3.4 Exemples de code == 
-<tabs> 
-  * [[#tab-pico_3|RPi Pico]] 
-  * [[#tab-esp32_3|ESP32]] 
- 
-<pane id="tab-pico_3"> 
-<html><p style="color:red">A faire</a></html> 
- 
-//Exemple de code pour un **Raspberry Pi Pico**// 
-<code python *.py> 
-</code> 
- 
-</pane> 
- 
-<pane id="tab-esp32_3"> 
-  * **Ressource** : <html><a href="https://docs.micropython.org/en/latest/esp8266/tutorial/pins.html?highlight=interrupt" target="_blank"><strong>Quick reference for ESP32</strong>, GPIO Pins, External interrupts</a></html> sur Micropython.org. 
- 
-//Exemple de code pour un **ESP32 Feather Huzzah**// 
-<code python *.py> 
-# Code partiel du programme HORLOGE 
- 
-# Réglage de l'heure à la mise sous tension  
-time_offset=12*3600+0*60+0 # hh+mm+ss 
- 
-# Routines de service d'interruption (ISR) 
-def handle_interrupt_min(pin): 
-    global time_offset 
-    time_offset+=60 
-    time.sleep(.2) 
- 
-def handle_interrupt_hr(pin): 
-    global time_offset 
-    time_offset+=3600 
-    time.sleep(.2) 
- 
-# Réglage des minutes 
-# Ajout de 60s à l'heure initiale 
-button_min = Pin(25, Pin.IN) 
-# Gestionnaire d'interruption 
-button_min.irq(trigger=Pin.IRQ_RISING,handler=handle_interrupt_min) 
- 
-# Réglage des heures 
-# Ajout de 3600s à l'heure initiale 
-button_hr = Pin(26, Pin.IN) 
-# Gestionnaire d'interruption 
-button_hr.irq(trigger=Pin.IRQ_RISING,handler=handle_interrupt_hr) 
-{{ :python:micropython:materiel:thonny.png?nolink&70|}} 
-</code> 
-<callout type="tip" icon="true"><html><strong><a href="https://webge.fr/doc/wikis/code/micropython/MICROPYTHON_ESP32_HORLOGE.zip" target="_blank">Télécharger</a></strong></html> le projet MICROPYTHON_ESP32_HORLOGE pour Thonny. </callout> 
-</pane> 
-</tabs> 
-{{ :python:micropython:youtube.png?nolink&50|}} 
-<callout type="info" icon="true">A voir : la vidéo de démonstration sur <html><a href="https://youtu.be/FGXCdyn_A9A" target="_blank">Youtube</a></html></callout> 
- 
-{{ :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://zestedesavoir.com/tutoriels/686/arduino-premiers-pas-en-informatique-embarquee/745_les-grandeurs-analogiques/3430_les-entrees-analogiques-de-larduino/" target="_blank">Un signal analogique : petits rappels</a></html> sur le site Zeste de savoir. 
-{{ :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"> 
-  * **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> | <html><a href="https://docs.micropython.org/en/latest/library/machine.Pin.html" target="_blank">class Pin – control I/O pins</a></html> sur Micropython.org. 
-//Exemple de code pour un **Raspberry Pi Pico**// 
-<code python *.py> 
-# ------------------------------------------------------------------------------- 
-# Lecture et affichage dans la console de la tension issue d'un potentiomètre  
-# Date : 22/5/2023 
-# Matériels : Raspberry Pi Pico, Shield Grove, pot. 10k 
-# ADC accessibles sur le shield Grove pour RP2 : 
-# Connecteur: ADC      : GPIO 
-#        A0 : ADC0     : 26 
-#        A1 : ADC0,ADC1: 26,27 
-#        A2 : ADC1,ADC2: 27,28 
-# IDE : Thonny 
-# ------------------------------------------------------------------------------- 
-from machine import ADC, Pin 
-import time 
- 
-# Le potentiomètre 10kOhm est connecté à l'entrée analogique A0 du shield. 
-# Attention : La tension doit être comprise entre 0 - 3,3V (3,6V max !) 
-# sur une entrée analogique. 
-# Configuration 
-pot = ADC(Pin(26))  
- 
-while (True): 
-    val=pot.read_u16() # lecture de l'ADC 
-    U = val*3.3/65535 # Calcul de la tension 
-    print("%.2f" % U) # Affichage dans la console (formaté à 2 décimales) 
-    time.sleep(1) 
-</code> 
-</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> 
- 
  
  • python/micropython/es.1692510134.txt.gz
  • Dernière modification : 2023/08/20 07:42
  • de phil