td1suite
Dependencies: lib_LCD_i2c_SPTLYI mbed
capteur.cpp@0:24f677c563ac, 2014-10-23 (annotated)
- Committer:
- mbedo
- Date:
- Thu Oct 23 12:11:14 2014 +0000
- Revision:
- 0:24f677c563ac
td1suite;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedo | 0:24f677c563ac | 1 | #include "mbed.h" |
mbedo | 0:24f677c563ac | 2 | #include "lib_SHT11.h" |
mbedo | 0:24f677c563ac | 3 | #include "lib_LCD_i2c_SPTLYI.h" |
mbedo | 0:24f677c563ac | 4 | SHT11 sensor(p30,p29,2.0); |
mbedo | 0:24f677c563ac | 5 | LCD_I2C LCD(p28,p27,p26,0x7C); |
mbedo | 0:24f677c563ac | 6 | |
mbedo | 0:24f677c563ac | 7 | |
mbedo | 0:24f677c563ac | 8 | int main() |
mbedo | 0:24f677c563ac | 9 | { |
mbedo | 0:24f677c563ac | 10 | LCD.set_position_cursor(0,0); |
mbedo | 0:24f677c563ac | 11 | LCD.print("temp:"); |
mbedo | 0:24f677c563ac | 12 | LCD.set_position_cursor(0,1); |
mbedo | 0:24f677c563ac | 13 | LCD.print("hum:"); |
mbedo | 0:24f677c563ac | 14 | while(1) |
mbedo | 0:24f677c563ac | 15 | { |
mbedo | 0:24f677c563ac | 16 | LCD.set_position_cursor(5,0); |
mbedo | 0:24f677c563ac | 17 | LCD.print("%.2f%cC",sensor.lire_T(),0xDF); |
mbedo | 0:24f677c563ac | 18 | wait(5); |
mbedo | 0:24f677c563ac | 19 | |
mbedo | 0:24f677c563ac | 20 | LCD.set_position_cursor(4,1); |
mbedo | 0:24f677c563ac | 21 | LCD.print("%.2f%c",sensor.lire_H(),37); // LCD.print(1,2,3) |
mbedo | 0:24f677c563ac | 22 | |
mbedo | 0:24f677c563ac | 23 | //1: placement de caractères %d (entier) %f(flottant) : %.'nombre'f pour nombre de chiffres ap virgule %c pour caractère (ex l 17 pour le C) |
mbedo | 0:24f677c563ac | 24 | //2: nom du composant: ici c'est sensor(p30 machin) suivit d'un point et du nom de la fonction(lire_T) |
mbedo | 0:24f677c563ac | 25 | //3: chiffre(cf table de translation ciffre=>caractère) du caractère installé avec le %c |
mbedo | 0:24f677c563ac | 26 | |
mbedo | 0:24f677c563ac | 27 | }} |