[[:python:micropython:accueil|{{ :iconemaison.jpg?nolink&30|Sommaire MicroPython, CircuitPython}}]] ===== MicroPython - Gestion du temps ===== {{ :micropython:logomicropython.png?nolink&120|}} [Mise à jour le : 29/7/2022] En cours de rédaction * **Ressources** * MicroPython.org * MicroPython documentation * IDE Thonny * **Lectures connexes** * MicroPython : ESP32 Sources de sommeil profond et de réveil * MicroPython : Sources de veille profonde et de réveil ESP8266 ==== 1. Présentation ==== ==== 2. Module time ==== {{ :python:micropython:materiel:led.jpg?nolink&50|LED}} * **Ressource** : Documentation sur docs.micropython.org. * //Exemple pour un **ESP32 Feather Huzzah** (LED #13)// # Faire clignoter la led de la carte from machine import Pin import time # Led de la carte Led = Pin(13, Pin.OUT) while(True): Led.on() time.sleep(1) Led.off() time.sleep(1) * //Exemples pour un **Raspberry Pi Pico** (LED #25)// # Exemple 1 # Faire clignoter la led de la carte # A modifier dans le code ci-dessus ... Led = Pin(25, Pin.OUT) ... {{ :python:micropython:morse.png?nolink&50|}} # Exemple 2 # Titre : Message en Morse # Sources # Elektor n°488, # https://fr.wikipedia.org/wiki/Code_Morse_international # fichier : morse.py import time from machine import Pin led=Pin(25,Pin.OUT) # Led de la carte BlinkRate=0.25 # Code complet téléchargeable à partir du lien ci-dessous {{ :python:micropython:materiel:thonny.png?nolink&70|}} Télécharger le projet MICROPYTHON_RPI2_MORSE pour Thonny. ==== 3. Module Timer ==== * //Exemple pour un **Raspberry Pi Pico**// {{ :python:micropython:materiel:led.jpg?nolink&50|LED}} # Faire clignoter la Led de la carte # Ressource : https://docs.micropython.org/en/latest/rp2/quickref.html from machine import Pin, Timer led = Pin(25, Pin.OUT) timer = Timer() def blink(timer): led.toggle() timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink) ==== 3. ==== * **Ressource** : sur Micropython.org. * **Matériel** : * //Exemple// ==== 4. ==== * **Ressource** : sur Micropython.org. * **Matériel** : * //Exemple//