Ligne 82 : |
Ligne 82 : |
| | | |
| == Un exemple simple == | | == Un exemple simple == |
− | For fun, lets try to build a traffic light. Add the following code to the {{fname|main.py}} file:
| + | Nous allons maintenant réaliser un feux de signalisation tricolore pour nous amuser. |
| + | |
| + | Ajouter le code suivant dans votre fichier {{fname|main.py}} : |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
Ligne 88 : |
Ligne 90 : |
| import time | | import time |
| pycom.heartbeat(False) | | pycom.heartbeat(False) |
− | for cycles in range(10): # stop after 10 cycles | + | for cycles in range(10): # arreter apres 10 cycles |
− | pycom.rgbled(0x007f00) # green | + | pycom.rgbled(0x007f00) # vert |
| time.sleep(5) | | time.sleep(5) |
− | pycom.rgbled(0x7f7f00) # yellow | + | pycom.rgbled(0x7f7f00) # jaune |
| time.sleep(1.5) | | time.sleep(1.5) |
− | pycom.rgbled(0x7f0000) # red | + | pycom.rgbled(0x7f0000) # rouge |
| time.sleep(4) | | time.sleep(4) |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
− | * Make sure the connection to your board is open in the Pycom Console | + | * Vérifiez que la connexion vers votre carte est bien ouverte dans la console Pycom |
− | * Press the sync button on the top toolbar. Any progress will be shown in the console. | + | * Pressez le bouton de synchronisation dans la barre d'outils (vous devriez voir des messages de progression apparaître dans la console). |
| | | |
− | Here is the expected result:
| + | Voici ce que vous devriez voir à l'écran: |
| | | |
| [[Fichier:Hack-pycom-esp 32-60.gif]] | | [[Fichier:Hack-pycom-esp 32-60.gif]] |
| | | |
− | You now have a traffic light in your hands. To stop a running program, use ctrl-c or do a right click on the console and press Reset. You can also reboot the board by pressing the physical {{fname|reset}} button.
| + | Voila! vous avez un feux tricolore sous la main. Vous pouvez utiliser la combinaison de touche ctrl-c pour arrêter le programme (ou sélectionner l'option "Reset" dans le menu contextuel de la console). |
| + | |
| + | Il est également possible d'arrêter le programme en pressant le bouton "Reset" (réinitialisation physique) de la carte. |
| | | |
− | {{ambox-stop|text=If your board is running code at boot time, you might need to boot it in safe mode.}} | + | {{ambox-stop|text=Si votre carte exécute le code au démarrage (dans le fichier boot.py), vous pourriez avoir besoin de la démarrer en "Safe mode".}} |
| | | |
| == Console Pycom == | | == Console Pycom == |