Bruno St-Georges
/
Question1
q1
Question1.cpp@0:08a662629d8a, 2019-10-22 (annotated)
- Committer:
- brunostgr
- Date:
- Tue Oct 22 13:42:41 2019 +0000
- Revision:
- 0:08a662629d8a
q1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brunostgr | 0:08a662629d8a | 1 | #include "mbed.h" |
brunostgr | 0:08a662629d8a | 2 | |
brunostgr | 0:08a662629d8a | 3 | AnalogIn analog_value(PA_0); // Entree analogique |
brunostgr | 0:08a662629d8a | 4 | Serial PC(USBTX, USBRX); // Port USB |
brunostgr | 0:08a662629d8a | 5 | |
brunostgr | 0:08a662629d8a | 6 | // Programme principal |
brunostgr | 0:08a662629d8a | 7 | int main() |
brunostgr | 0:08a662629d8a | 8 | { |
brunostgr | 0:08a662629d8a | 9 | // Declaration des variables |
brunostgr | 0:08a662629d8a | 10 | float mesure; |
brunostgr | 0:08a662629d8a | 11 | float nombre; |
brunostgr | 0:08a662629d8a | 12 | |
brunostgr | 0:08a662629d8a | 13 | while(1) { |
brunostgr | 0:08a662629d8a | 14 | |
brunostgr | 0:08a662629d8a | 15 | mesure = analog_value.read(); // Assigne une valeur de 0.0 à 1.0 a mesure |
brunostgr | 0:08a662629d8a | 16 | nombre = mesure * 4095; // Conversion vers un 12-bit integer |
brunostgr | 0:08a662629d8a | 17 | |
brunostgr | 0:08a662629d8a | 18 | // Affichage du nombre a 12 bits |
brunostgr | 0:08a662629d8a | 19 | PC.printf("Lecture = 0x%X",(unsigned)nombre); |
brunostgr | 0:08a662629d8a | 20 | } |
brunostgr | 0:08a662629d8a | 21 | } |