Bruno St-Georges
/
Question3
q3
Question3.cpp@0:9b0238b70cf2, 2019-10-22 (annotated)
- Committer:
- brunostgr
- Date:
- Tue Oct 22 13:41:58 2019 +0000
- Revision:
- 0:9b0238b70cf2
q3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brunostgr | 0:9b0238b70cf2 | 1 | #include "mbed.h" |
brunostgr | 0:9b0238b70cf2 | 2 | |
brunostgr | 0:9b0238b70cf2 | 3 | AnalogIn analog_value(PA_0); // Entree analogique |
brunostgr | 0:9b0238b70cf2 | 4 | Serial PC(USBTX, USBRX); // Port USB |
brunostgr | 0:9b0238b70cf2 | 5 | |
brunostgr | 0:9b0238b70cf2 | 6 | Ticker afficheur; |
brunostgr | 0:9b0238b70cf2 | 7 | |
brunostgr | 0:9b0238b70cf2 | 8 | // Declaration des variables |
brunostgr | 0:9b0238b70cf2 | 9 | float mesure; |
brunostgr | 0:9b0238b70cf2 | 10 | float temp; |
brunostgr | 0:9b0238b70cf2 | 11 | |
brunostgr | 0:9b0238b70cf2 | 12 | void affiche(){ // Fonction d'affichage |
brunostgr | 0:9b0238b70cf2 | 13 | |
brunostgr | 0:9b0238b70cf2 | 14 | mesure = analog_value.read(); // Assigne une valeur de 0.0 à 1.0 a mesure |
brunostgr | 0:9b0238b70cf2 | 15 | temp = mesure * 330; // Conversion en degres Celsius |
brunostgr | 0:9b0238b70cf2 | 16 | |
brunostgr | 0:9b0238b70cf2 | 17 | // Affichage de la temperature |
brunostgr | 0:9b0238b70cf2 | 18 | PC.printf("Temperature = %u C",(unsigned)temp); |
brunostgr | 0:9b0238b70cf2 | 19 | } |
brunostgr | 0:9b0238b70cf2 | 20 | |
brunostgr | 0:9b0238b70cf2 | 21 | // Programme principal |
brunostgr | 0:9b0238b70cf2 | 22 | int main() |
brunostgr | 0:9b0238b70cf2 | 23 | { |
brunostgr | 0:9b0238b70cf2 | 24 | afficheur.attach(&affiche,0.1); // Ticker appele a toutes les 100 ms |
brunostgr | 0:9b0238b70cf2 | 25 | while(1) { |
brunostgr | 0:9b0238b70cf2 | 26 | // Attente |
brunostgr | 0:9b0238b70cf2 | 27 | } |
brunostgr | 0:9b0238b70cf2 | 28 | } |