avec fonctions
Dependencies: DHT22 SSD1306 TCS34725 mbed
Fork of ProjetLong_Serre_V2 by
main.cpp
- Committer:
- leandre
- Date:
- 2018-09-18
- Revision:
- 0:3c21f316aef8
- Child:
- 1:6a83787ddf2d
File content as of revision 0:3c21f316aef8:
#include "mbed.h" #include "ssd1306.h" #include "standard_font.h" #include "bold_font.h" #include "DHT22.h" SSD1306 oled(PB_0,PB_4,PB_5,PA_5,PA_7); // OLED : CS,Reset,DC,Clock,Data I2C i2c(PB_7,PB_6); DigitalOut myled(LED1); DHT22 dht22(D4); int main() { float hum; float temp; oled.initialise(); oled.clear(); oled.set_contrast(255); // max contrast oled.update(); while(1) { wait(1.0); // 1 sec dht22.sample() ; hum=dht22.getHumidity()/10.0; temp=dht22.getTemperature()/10.0; oled.clear(); oled.set_font(bold_font, 8); oled.printf("DHT22\r\n"); oled.printf("\r\n"); oled.set_font(standard_font, 6); oled.printf("Humidite: %.2f %%\r\n", hum); oled.printf("Temperature: %.2f C\r\n", temp); oled.printf("\r\n"); oled.update(); printf("temp: %.2f C , hum:%.2f %% \n\r",temp,hum); } }