Modifications

Sauter à la navigation Sauter à la recherche
254 octets ajoutés ,  28 avril 2015 à 20:51
Ligne 39 : Ligne 39 :     
== Le code ==
 
== Le code ==
By examining the Quick reference for the pyboard, we see that X1 is connected to canal 1 (''channel 1'') du Timer 5 (noté ''TIM5 CH1'' sur le schéma).
+
En examinant le graphique de référence de la carte PyBoard (ci-dessous), nous pouvons constater que la broche X1 est est connectée sur le canal 1 ( dit ''channel 1'') du Timer 5. Regarder le graphique, vous noterez la terminologie ''TIM5 CH1'' pour X1.
    
{{MPImage|pybv10-pinout.jpg|800px}}
 
{{MPImage|pybv10-pinout.jpg|800px}}
   −
Therefore we will first create a Timer object for timer 5, then create a TimerChannel object for channel 1:
+
TPar conséquent, nous allons d'abord créer un objet {{fname|Timer}} pour le timer 5 PUIS nous allons créer un objet {{fname|TimerChannel}} pour le canal 1:
    
  <nowiki>from pyb import Timer
 
  <nowiki>from pyb import Timer
 
from time import sleep
 
from time import sleep
   −
# timer 5 will be created with a frequency of 100 Hz
+
# Le timer 5 sera créer à une fréquence de 100 Hz
 
tim = pyb.Timer(5, freq=100)
 
tim = pyb.Timer(5, freq=100)
 
tchannel = tim.channel(1, Timer.PWM, pin=pyb.Pin.board.X1, pulse_width=0)</nowiki>
 
tchannel = tim.channel(1, Timer.PWM, pin=pyb.Pin.board.X1, pulse_width=0)</nowiki>
   −
Brightness of the LED in PWM is controlled by controlling the pulse-width, that is the amount of time the LED is on every cycle. With a timer frequency of 100 Hz, each cycle takes 0.01 second, or 10 ms.
+
La luminosité de la LED est contrôlée par la largeur d'impulsion du signal PWM, cela correspond à la quantité de temps durant laquelle la LED est allumée durant chaque cycle PWM.
    +
Avec le timer à une fréquence de 100 Hz, chaque cycle est prends 0.01 seconde (ou 10 millisecondes).
 +
 +
{{traduction}}
    
To achieve the fading effect shown at the beginning of this tutorial, we want to set the pulse-width to a small value, then slowly increase the pulse-width to brighten the LED, and start over when we reach some maximum brightness:
 
To achieve the fading effect shown at the beginning of this tutorial, we want to set the pulse-width to a small value, then slowly increase the pulse-width to brighten the LED, and start over when we reach some maximum brightness:
29 917

modifications

Menu de navigation