Modifications

Sauter à la navigation Sauter à la recherche
1 630 octets ajoutés ,  16 février 2015 à 11:54
Ligne 28 : Ligne 28 :     
== Editer main.py ==
 
== Editer main.py ==
{{traduction}}
+
Now we are going to write our Python program, so open the main.py file in a text editor. On Windows you can use notepad, or any other editor. On Mac and Linux, use your favourite text editor. With the file open you will see it contains 1 line:
 +
 
 +
<nowiki># main.py -- put your code here! (Placez votre code ici!)</nowiki>
 +
 
 +
This line starts with a # character, which means that it is a comment. Such lines will not do anything, and are there for you to write notes about your program.
 +
 
 +
Let’s add 2 lines to this {{fname|main.py}} file, to make it look like this:
 +
 
 +
<nowiki># main.py -- put your code here!
 +
import pyb
 +
pyb.LED(4).on()</nowiki>
 +
 
 +
The first line we wrote says that we want to use the {{fname|pyb}} module. This module contains all the functions and classes to control the features of the pyboard.
 +
 
 +
The second line that we wrote turns the blue LED on: it first gets the {{fname|LED}} class from the {{fname|pyb}} module, creates LED number 4 (the blue LED), and then turns it on.
 +
 
 +
== Réinitialiser la carte PyBoard ==
 +
To run this little script, you need to first save and close the {{fname|main.py}} file, and then eject (or unmount) the pyboard USB drive. Do this like you would a normal USB flash drive.
 +
 
 +
When the drive is safely ejected/unmounted you can get to the fun part: press the RST switch on the pyboard to reset and run your script. The RST switch is the small black button just below the USB connector on the board, on the right edge.
 +
 
 +
When you press RST the green LED will flash quickly, and then the blue LED should turn on and stay on.
 +
 
 +
Congratulations! You have written and run your very first Micro Python program!
    
{{MicroPython-Hack-first-script-TRAILER}}
 
{{MicroPython-Hack-first-script-TRAILER}}
29 917

modifications

Menu de navigation