![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Devoir Maison d'ER1 Exercice n°1
main.cpp@0:51f7a12253d1, 2018-10-19 (annotated)
- Committer:
- vermaelen
- Date:
- Fri Oct 19 09:35:54 2018 +0000
- Revision:
- 0:51f7a12253d1
- Child:
- 1:a51043da3ab9
Exercice 1 - DM ER1; Version 1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vermaelen | 0:51f7a12253d1 | 1 | #include "mbed.h" |
vermaelen | 0:51f7a12253d1 | 2 | #include "tsi_sensor.h" |
vermaelen | 0:51f7a12253d1 | 3 | #include "lib.h" |
vermaelen | 0:51f7a12253d1 | 4 | |
vermaelen | 0:51f7a12253d1 | 5 | PwmOut led(LED_GREEN); //déclaration de la sortie PWM |
vermaelen | 0:51f7a12253d1 | 6 | |
vermaelen | 0:51f7a12253d1 | 7 | int main(void) { |
vermaelen | 0:51f7a12253d1 | 8 | float val; //déclaration des variables |
vermaelen | 0:51f7a12253d1 | 9 | float t_etat_haut; |
vermaelen | 0:51f7a12253d1 | 10 | led.period(0.001); //periode de la PWM = 0.001 s = 1 ms |
vermaelen | 0:51f7a12253d1 | 11 | while (1) { //boucle infinie |
vermaelen | 0:51f7a12253d1 | 12 | val=lire_slider(); //lecture du slider (valeur comprise entre 0 et 1) |
vermaelen | 0:51f7a12253d1 | 13 | t_etat_haut=val*0.001; //on fixe la durée du temps haut en fonction de val |
vermaelen | 0:51f7a12253d1 | 14 | led.pulsewidth(t_etat_haut);//écriture de l'état haut |
vermaelen | 0:51f7a12253d1 | 15 | wait(0.1); //attente de 100 ms |
vermaelen | 0:51f7a12253d1 | 16 | } |
vermaelen | 0:51f7a12253d1 | 17 | } |