Modifications

Sauter à la navigation Sauter à la recherche
872 octets ajoutés ,  19 février 2017 à 16:31
Ligne 169 : Ligne 169 :     
{{tmbox| type = speedy |text=The changes you make to your file won’t be automatically saved to the device on execution.}}
 
{{tmbox| type = speedy |text=The changes you make to your file won’t be automatically saved to the device on execution.}}
 +
 +
== Un exemple simple ==
 +
For fun, lets try again to build a traffic light. Add the following code to the main.py file:
 +
 +
<syntaxhighlight lang="python">
 +
import pycom
 +
import time
 +
pycom.heartbeat(False)
 +
for cycles in range(10): # Arreter apres 10 cycles
 +
    pycom.rgbled(0x007f00) # vert
 +
    time.sleep(5)
 +
    pycom.rgbled(0x7f7f00) # jaune
 +
    time.sleep(1.5)
 +
    pycom.rgbled(0x7f0000) # rouge
 +
    time.sleep(4)
 +
</syntaxhighlight>
 +
 +
* Make sure the connection to your board is open in the Pycom Console
 +
* Press the sync button on the top toolbar. Any progress will be shown in the console.
 +
 +
Here is the expected result:
 +
 +
[[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.
 +
 +
    
{{LOPY-TRAILER}}
 
{{LOPY-TRAILER}}
29 917

modifications

Menu de navigation