Ligne 30 : |
Ligne 30 : |
| == Hello World == | | == Hello World == |
| | | |
− | Ok we can now turn on an LED. There is a red LED on each board, connected to '''GPIO #0'''
| + | Nous pouvons maintenant allumer une LED. Il y a une LED rouge sur chaque carte, elle est connectée sur le broche '''GPIO #0''' |
| | | |
− | {{ambox|text=NodeMCU's pinouts are not the same as the Arduino/gcc pinouts. We print the Arduino pinouts on the board so watch out!}} | + | {{ambox|text=La numérotation des broches de NodeMCU n'est pas identique à celle utilisée pour Arduino/gcc. Adafruit à imprimé la numérotation Arduino sur les cartes... faites attention!}} |
| | | |
− | {{ambox|text=The Lua documentation for the ESP8266 has GPIO #4 and #5 swapped so if #4/#5 aren't working for you, try swapping!}} | + | {{ambox|text=La documentation Lua pour l'ESP8266 a inversé les GPIO #4 et #5 swapped. Si les brcohes #4/#5 ne fonctionnent pas comme attendu, essayez de les inverser!}} |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
| |- | | |- |
− | | align="center" | Pin Notes | + | | align="center" | Note concernant<br />la broche |
− | | align="center" | PCB/Arduino | + | | align="center" | Carte/Arduino |
| | align="center" | NodeMCU/Lua | | | align="center" | NodeMCU/Lua |
| |- style="font-size: 90%" | | |- style="font-size: 90%" |
Ligne 91 : |
Ligne 91 : |
| |} | | |} |
| | | |
− | So to set the pin #0 LED on and off (which would be pin #3 in Lua) first make it an output:
| + | Par conséquent, pour allumer ou éteindre la LED sur la broche #0 (qui sera la broche #3 dans Lua), nous allons configurer la broche en sortie: |
| | | |
| <nowiki>gpio.mode(3, gpio.OUTPUT)</nowiki> | | <nowiki>gpio.mode(3, gpio.OUTPUT)</nowiki> |
| | | |
− | Turn the LED on with:
| + | Allumer la LED avec: |
| | | |
| <nowiki>gpio.write(3, gpio.LOW)</nowiki> | | <nowiki>gpio.write(3, gpio.LOW)</nowiki> |
| | | |
− | Et eteindre la LED: | + | Et éteindre la LED: |
| | | |
| <nowiki>gpio.write(3, gpio.HIGH)</nowiki> | | <nowiki>gpio.write(3, gpio.HIGH)</nowiki> |
| | | |
− | You can make this a little more automated by running:
| + | Nous pouvons automatiser un peu les choses en utilisant le code suivant: |
| | | |
| <nowiki>while 1 do | | <nowiki>while 1 do |
| gpio.write(3, gpio.HIGH) | | gpio.write(3, gpio.HIGH) |
− | tmr.delay(1000000) -- wait 1,000,000 us = 1 second | + | tmr.delay(1000000) -- attendre 1.000.000 µs = 1 seconde |
| gpio.write(3, gpio.LOW) | | gpio.write(3, gpio.LOW) |
− | tmr.delay(1000000) -- wait 1,000,000 us = 1 second | + | tmr.delay(1000000) -- attendre 1.000.000 µs = 1 seconde |
| end</nowiki> | | end</nowiki> |
| | | |
| + | Ce qui fait clignoter LED en continu. |
| | | |
− | The LED will now be blinking on and off.
| + | {{underline|Note:}} |
| | | |
− | Note that since its in a loop, its not possible to get it to stop via the interpretter. To stop it, click the '''Reset''' button again!
| + | Etant donné que c'est une boucle infinie, il n'est pas possible de l'arrêter via l'interpréteur. Pressez une nouvelle fois le bouton '''Reset''' pour arrêter la boucle! |
| | | |
| == Scanner le réseau WiFi et connexion == | | == Scanner le réseau WiFi et connexion == |