| |
| microc:gpio [2025/02/19 12:14] – [Modifier - Pane] phil | microc:gpio [2025/06/19 19:24] (Version actuelle) – modification externe 127.0.0.1 |
|---|
| # Exemple 1 : configuration en sortie de la broche 15 connectée à une led | # Exemple 1 : configuration en sortie de la broche 15 connectée à une led |
| led = Pin(15,Pin.OUT) # Associée à Pin.OUT, Pin force la broche 15 de la carte Rpi Pico à se comporter comme une sortie | led = Pin(15,Pin.OUT) # Associée à Pin.OUT, Pin force la broche 15 de la carte Rpi Pico à se comporter comme une sortie |
| | # ou |
| | led = Pin(Pin.board.GP15,Pin.OUT) # pour plus de clarté |
| |
| # Exemple 2 : configuration en sortie de la broche associée à la led de la carte | # Exemple 2 : configuration en sortie de la broche associée à la led de la carte |
| led_carte = Pin('LED',Pin.OUT) # 'LED' <=> 25 (GPIO25) # Associée à Pin.OUT, Pin force la broche 25 de la carte Rpi Pico | led_carte = Pin('LED',Pin.OUT) # 'LED' <=> 25 (GPIO25) # Associée à Pin.OUT, Pin force la broche 25 de la carte Rpi Pico |
| # à se comporter comme une sortie | # à se comporter comme une sortie |
| </code> | </code> |
| |
| | |
| # Configuration de la broche associée à la led de la carte | # Configuration de la broche associée à la led de la carte |
| led = Pin(15,Pin.OUT) # (GPIO15) | led = Pin(Pin.board.GP15,Pin.OUT) # (GPIO15) |
| | |
| while (True): | while (True): |
| * En langage **C** sur Arduino Uno ou compatible | * En langage **C** sur Arduino Uno ou compatible |
| * En langage **MicroPython** sur Raspberry Pi Pico et ESP32 | * En langage **MicroPython** sur Raspberry Pi Pico et ESP32 |
| | |
| <nav type="pills"> | <nav type="pills"> |
| * [[#tab-uno_2|Arduino Uno R3]] | * [[#tab-unor3_4|Arduino UNO R3]] |
| * [[#tab-pico_2|RPi Pico]] | * [[#tab-rpipico_4|Rpi pico & picoW]] |
| * [[#tab-esp32_2|ESP32]] | * [[#tab-esp32_4|ESP32]] |
| |
| <pane id="tab-uno_2"> | <pane id="tab-unor3_4"> |
| * **Ressource** : <html><a href="https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/" target="_blank">analogWrite()</a></html> sur le site <html><a href="https://www.arduino.cc/" target="_blank">arduino.cc</a></html> | * **Ressource** : <html><a href="https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/" target="_blank">analogWrite()</a></html> sur le site <html><a href="https://www.arduino.cc/" target="_blank">arduino.cc</a></html> |
| |
| {{ :arduino:arduino.png?nolink&60|}} | {{ :arduino:arduino.png?nolink&60|}} |
| //a. Présentation// | * //a. Présentation// \\ |
| ^ Cartes ^ Broche PWM ^ Fréquence ^ Repérage de la broche PWM sur la carte ^ | |
| | ^ Cartes ^ Broche PWM ^ Fréquence ^ Repérage de la broche PWM sur la carte ^ \\ |
| |Uno, Nano, Mini|3, 5, 6, 9, 10, 11|490 Hz (broches 5 et 6: 980 Hz)| ~ | | |Uno, Nano, Mini|3, 5, 6, 9, 10, 11|490 Hz (broches 5 et 6: 980 Hz)| ~ | |
| |
| <callout type="primary" icon="true" title="SCHEMA DE LA CARTE">Téléchargeable <html><a href="http://marcusjenkins.com/wp-content/uploads/2014/06/ARDUINO_V2.pdf" target="_blank" title="pdf">ici</a></html>.</callout> | <callout type="primary" icon="true" title="SCHEMA DE LA CARTE">Téléchargeable <html><a href="http://marcusjenkins.com/wp-content/uploads/2014/06/ARDUINO_V2.pdf" target="_blank" title="pdf">ici</a></html>.</callout> |
| |
| //b. Configuration d'une broche en sortie et génération d'un signal PWM // | * //b. Configuration d'une broche en sortie et génération d'un signal PWM // |
| <code cpp *.cpp> | <code cpp *.cpp> |
| // Exemple | // Exemple |
| </pane> | </pane> |
| |
| <pane id="tab-pico_2"> | <pane id="tab-rpipico_4"> |
| <html><span style="color:red">A faire</a></html> | * <html><span style="color:red">A faire</a></html> |
| </pane> | </pane> |
| |
| <pane id="tab-esp32_2"> | <pane id="tab-esp32_4"> |
| <html><span style="color:red">A faire</a></html> \\ | * <html><span style="color:red">A faire</a></html> \\ |
| Ressource provisoire <html><a href="https://randomnerdtutorials.com/esp32-esp8266-pwm-micropython/" target="_blank">ESP32/ESP8266 PWM with MicroPython – Dim LED</a></html> | Ressource provisoire <html><a href="https://randomnerdtutorials.com/esp32-esp8266-pwm-micropython/" target="_blank">ESP32/ESP8266 PWM with MicroPython – Dim LED</a></html> |
| </pane> | </pane> |
| * En langage **C** sur Arduino Uno ou compatible | * En langage **C** sur Arduino Uno ou compatible |
| * En langage **MicroPython** sur Raspberry Pi Pico et ESP32 | * En langage **MicroPython** sur Raspberry Pi Pico et ESP32 |
| <tabs> | |
| * [[#tab-uno_3|Arduino Uno]] | |
| * [[#tab-pico_3|RPi Pico]] | |
| * [[#tab-esp32_3|ESP32]] | |
| |
| <pane id="tab-uno_3"> | <nav type="pills"> |
| //a. Présentation// \\ | * [[#tab-unor3_5|Arduino UNO R3]] |
| Toutes les broches d'E/S de la carte Arduino Uno peuvent servir d'entrées, sorties numériques. Cela inclut les broches numérotées entre **0** et **13**, mais aussi les broches **A0** à** A5**. Le symbole **~** identifie les broches capables de délivrer un signal numérique **PWM** (**P**ulse **W**ith **M**odulation). \\ \\ | * [[#tab-rpipico_5|Rpi pico & picoW]] |
| | * [[#tab-esp32_5|ESP32]] |
| | |
| | <pane id="tab-unor3_5"> |
| | * //a. Présentation// \\ Toutes les broches d'E/S de la carte Arduino Uno peuvent servir d'entrées, sorties numériques. Cela inclut les broches numérotées entre **0** et **13**, mais aussi les broches **A0** à** A5**. Le symbole **~** identifie les broches capables de délivrer un signal numérique **PWM** (**P**ulse **W**ith **M**odulation). \\ \\ |
| |
| {{ :microc:unogpio.png?nolink |}} | {{ :microc:unogpio.png?nolink |}} |
| |
| |
| //b. Configuration d'une broche en entrée// \\ | * //b. Configuration d'une broche en entrée// \\ |
| * **Ressource** : <html><a href="https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/" target="_blank">pinMode()</a></html> sur le site <html><a href="https://www.arduino.cc/" target="_blank">arduino.cc</a></html> | * **Ressource** : <html><a href="https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/" target="_blank">pinMode()</a></html> sur le site <html><a href="https://www.arduino.cc/" target="_blank">arduino.cc</a></html> |
| |
| <callout type="tip" icon="true" title="CONFIGURATION">**Configurer** une broche signifie qu'on précise qu'elle doit se comporter soit comme une **entrée d'information**, soit comme une sortie d'information.</callout> | <callout type="tip" icon="true" title="CONFIGURATION">**Configurer** une broche signifie qu'on précise qu'elle doit se comporter soit comme une **entrée d'information**, soit comme une sortie d'information.</callout> |
| </pane> | </pane> |
| |
| <pane id="tab-pico_3"> | <pane id="tab-rpipico_5"> |
| * **Ressources** sur Micropython.org. | * **Ressources** sur Micropython.org. |
| * <html><a href="https://docs.micropython.org/en/latest/library/machine.html?highlight=machine#module-machine" target="_blank">module machine</a></html> | <html><a href="https://docs.micropython.org/en/latest/library/time.html?highlight=time#module-time" target="_blank">module time</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> | * <html><a href="https://docs.micropython.org/en/latest/library/machine.html?highlight=machine#module-machine" target="_blank">module machine</a></html> | <html><a href="https://docs.micropython.org/en/latest/library/time.html?highlight=time#module-time" target="_blank">module time</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> |
| * <html><a href="https://docs.micropython.org/en/latest/rp2/quickref.html#pins-and-gpio" target="_blank">Quick reference for the RP2, Pins and GPIO </a></html> | * <html><a href="https://docs.micropython.org/en/latest/rp2/quickref.html#pins-and-gpio" target="_blank">Quick reference for the RP2, Pins and GPIO </a></html> |
| |
| //b. Configuration d'une broche en en entrée// \\ | * //b. Configuration d'une broche en en entrée// \\ |
| //c. Lecture de l'état logique sur une broche// \\ | |
| //d. Synthèse: ?.cpp// | * //c. Lecture de l'état logique sur une broche// \\ |
| | |
| | * //d. Synthèse: ?.cpp// |
| //Exemple de code pour un **Raspberry Pi Pico**// | //Exemple de code pour un **Raspberry Pi Pico**// |
| <code Python *.py> | <code Python *.py> |
| </pane> | </pane> |
| |
| <pane id="tab-esp32_3"> | <pane id="tab-esp32_5"> |
| * **Ressources** sur Micropython.org. | * **Ressources** sur Micropython.org. |
| * <html><a href="https://docs.micropython.org/en/latest/library/machine.html?highlight=machine#module-machine" target="_blank">module machine</a></html> | <html><a href="https://docs.micropython.org/en/latest/library/time.html?highlight=time#module-time" target="_blank">module time</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> | * <html><a href="https://docs.micropython.org/en/latest/library/machine.html?highlight=machine#module-machine" target="_blank">module machine</a></html> | <html><a href="https://docs.micropython.org/en/latest/library/time.html?highlight=time#module-time" target="_blank">module time</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> |
| * <html><a href="https://docs.micropython.org/en/latest/esp32/quickref.html#pins-and-gpio" target="_blank">Quick reference for the ESP32, Pins and GPIO</a></html> | * <html><a href="https://docs.micropython.org/en/latest/esp32/quickref.html#pins-and-gpio" target="_blank">Quick reference for the ESP32, Pins and GPIO</a></html> |
| |
| //b. Configuration d'une broche en en entrée// \\ | * //b. Configuration d'une broche en en entrée// \\ |
| //c. Lecture de l'état logique sur une broche// \\ | * //c. Lecture de l'état logique sur une broche// \\ |
| //d. Synthèse: ?.cpp// | * //d. Synthèse: ?.cpp// |
| //Exemple de code pour un **ESP32 Feather Huzzah**// | //Exemple de code pour un **ESP32 Feather Huzzah**// |
| <code python *.py> | <code python *.py> |
| </code> | </code> |
| </pane> | </pane> |
| </tabs> | </nav> |
| |
| \\ | \\ |