Modifications

Sauter à la navigation Sauter à la recherche
405 octets ajoutés ,  16 février 2015 à 22:43
Ligne 4 : Ligne 4 :     
== Activer les LEDs et concepts de base ==
 
== Activer les LEDs et concepts de base ==
{{bloc-etroit|text=The easiest thing to do on the pyboard is to turn on the LEDs attached to the board. Connect the board, and log in as described in tutorial 1. We will start by turning and LED on in the interpreter, type the following:}}
+
{{bloc-etroit|text=L'une des choses les plus faciles à faire sur une carte PyBoard est est d'allumer les LEDs qui sont montés sur la carte. Connectez la carte, et connectez vous sur la carte en REPL comme décrit dans le tutoriel précédent. Nous allons commencer par allumer une LED dans l’interpréteur en tapant la commande suivante:}}
    
  <nowiki>>>> myled = pyb.LED(1)
 
  <nowiki>>>> myled = pyb.LED(1)
Ligne 10 : Ligne 10 :  
>>> myled.off()</nowiki>
 
>>> myled.off()</nowiki>
   −
{{bloc-etroit|text=These commands turn the LED on and off.
+
{{bloc-etroit|text=Ces commandes allume (''on'') et éteint (''off'') la LED.
   −
This is all very well but we would like this process to be automated. Open the file MAIN.PY on the pyboard in your favourite text editor. Write or paste the following lines into the file. If you are new to python, then make sure you get the indentation correct since this matters!}}
+
Tout cela est très bien mais nous aimerions que ce processus soit automatisé. Ouvrez le fichier {{fname|main.py}} sur la carte PyBoard avec votre éditeur de texte favorit. Ecrivez (ou copiez/collez) les lignes suivantes dans le fichier. Si vous débutez en Python, assurez-vous de bien préserver l'indentation dans les différentes lignes, cela est vraiment très important!}}
    
  <nowiki>led = pyb.LED(2)
 
  <nowiki>led = pyb.LED(2)
Ligne 19 : Ligne 19 :  
     pyb.delay(1000)</nowiki>
 
     pyb.delay(1000)</nowiki>
   −
When you save, the red light on the pyboard should turn on for about a second. To run the script, do a soft reset (CTRL-D). The pyboard will then restart and you should see a green light continuously flashing on and off. Success, the first step on your path to building an army of evil robots! When you are bored of the annoying flashing light then press CTRL-C at your terminal to stop it running.
+
Lorsque vous sauvez le fichier, la LED rouge sur la carte doit s'allumer pendant environ une seconde. Pour exécuter le script, faite une réinitialisation logicielle (''soft reset'') en pressant (CTRL-D). La carte PyBoard va redémarrer et vous devriez voir la LED rouge clignoter continuellement. Ca marche? génial, vous venez de réaliser la première étape vous permettant de réaliser votre futur armée de petits robots! Lorsque vous serez lassé de voir la LED clignoter alors pressez la combinaison CTRL-C dans votre terminal pour interrompre l'exécution.
 +
 
 +
{{traduction}}
    
So what does this code do? First we need some terminology. Python is an object-oriented language, almost everything in python is a class and when you create an instance of a class you get an object. Classes have methods associated to them. A method (also called a member function) is used to interact with or control the object.
 
So what does this code do? First we need some terminology. Python is an object-oriented language, almost everything in python is a class and when you create an instance of a class you get an object. Classes have methods associated to them. A method (also called a member function) is used to interact with or control the object.
29 918

modifications

Menu de navigation