Exemple 1 CRTI
Dependencies: C12832 LM75B mbed
Fork of app-board-LM75B by
Diff: main.cpp
- Revision:
- 6:745bea53d3db
- Parent:
- 5:608f2bf4d3f7
diff -r 608f2bf4d3f7 -r 745bea53d3db main.cpp --- a/main.cpp Thu Feb 06 14:05:51 2014 +0000 +++ b/main.cpp Tue Dec 20 14:03:40 2016 +0000 @@ -1,28 +1,55 @@ #include "mbed.h" +#include "C12832.h" #include "LM75B.h" -#include "C12832.h" + C12832 lcd(p5, p7, p6, p8, p11); LM75B sensor(p28,p27); Serial pc(USBTX,USBRX); +Timer t; +AnalogIn simtemp (p19); +PwmOut r (p23); +PwmOut g (p24); +PwmOut b (p25); +Ticker periode; -int main () -{ - //Try to open the LM75B - if (sensor.open()) { - printf("Device detected!\n"); +volatile float dt; +volatile char flagtemp; +/////////////////////////////////////////////// +// fonction Flip pour gérer le timer 500ms + +void flip(){ + dt=sensor.temp(); + flagtemp=1; +} + - while (1) { - lcd.cls(); - lcd.locate(0,3); - lcd.printf("Temp = %.3f\n", (float)sensor); - wait(1.0); +int main() { + r.period(0.005); + g.period(0.005); + b.period(0.005); + g=1.0; + b=1.0; + lcd.cls(); + if (sensor.open()) { + pc.printf("Device detected!\n"); + }else { + pc.printf("Device not detected!\n"); } + periode.attach(&flip, 0.5); + // t.reset(); + while (1) { + //tx.start() + //Print the current temperature + if(flagtemp==1) { + pc.printf("Temp = %.3f\r\n", dt); + r = 1- (dt-25)/8.0 ; + flagtemp=0; + } + } +} - } else { - error("Device not detected!\n"); - } - -} +// lcd.copy_to_lcd(); // LCD.pixel does not update the lcd +// wait_us(3000);