Exemple 1 CRTI

Dependencies:   C12832 LM75B mbed

Fork of app-board-LM75B by Chris Styles

Committer:
bouaziz
Date:
Tue Dec 20 14:03:40 2016 +0000
Revision:
6:745bea53d3db
Parent:
5:608f2bf4d3f7
test CRTI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:ce7a8546502b 1 #include "mbed.h"
bouaziz 6:745bea53d3db 2 #include "C12832.h"
chris 2:9e757151de9b 3 #include "LM75B.h"
bouaziz 6:745bea53d3db 4
okano 0:ce7a8546502b 5
chris 5:608f2bf4d3f7 6 C12832 lcd(p5, p7, p6, p8, p11);
chris 5:608f2bf4d3f7 7
chris 4:6df97cb10041 8 LM75B sensor(p28,p27);
chris 4:6df97cb10041 9 Serial pc(USBTX,USBRX);
bouaziz 6:745bea53d3db 10 Timer t;
bouaziz 6:745bea53d3db 11 AnalogIn simtemp (p19);
bouaziz 6:745bea53d3db 12 PwmOut r (p23);
bouaziz 6:745bea53d3db 13 PwmOut g (p24);
bouaziz 6:745bea53d3db 14 PwmOut b (p25);
bouaziz 6:745bea53d3db 15 Ticker periode;
okano 0:ce7a8546502b 16
okano 0:ce7a8546502b 17
bouaziz 6:745bea53d3db 18 volatile float dt;
bouaziz 6:745bea53d3db 19 volatile char flagtemp;
bouaziz 6:745bea53d3db 20 ///////////////////////////////////////////////
bouaziz 6:745bea53d3db 21 // fonction Flip pour gérer le timer 500ms
bouaziz 6:745bea53d3db 22
bouaziz 6:745bea53d3db 23 void flip(){
bouaziz 6:745bea53d3db 24 dt=sensor.temp();
bouaziz 6:745bea53d3db 25 flagtemp=1;
bouaziz 6:745bea53d3db 26 }
bouaziz 6:745bea53d3db 27
chris 4:6df97cb10041 28
bouaziz 6:745bea53d3db 29 int main() {
bouaziz 6:745bea53d3db 30 r.period(0.005);
bouaziz 6:745bea53d3db 31 g.period(0.005);
bouaziz 6:745bea53d3db 32 b.period(0.005);
bouaziz 6:745bea53d3db 33 g=1.0;
bouaziz 6:745bea53d3db 34 b=1.0;
bouaziz 6:745bea53d3db 35 lcd.cls();
bouaziz 6:745bea53d3db 36 if (sensor.open()) {
bouaziz 6:745bea53d3db 37 pc.printf("Device detected!\n");
bouaziz 6:745bea53d3db 38 }else {
bouaziz 6:745bea53d3db 39 pc.printf("Device not detected!\n");
chris 4:6df97cb10041 40 }
bouaziz 6:745bea53d3db 41 periode.attach(&flip, 0.5);
bouaziz 6:745bea53d3db 42 // t.reset();
bouaziz 6:745bea53d3db 43 while (1) {
bouaziz 6:745bea53d3db 44 //tx.start()
bouaziz 6:745bea53d3db 45 //Print the current temperature
bouaziz 6:745bea53d3db 46 if(flagtemp==1) {
bouaziz 6:745bea53d3db 47 pc.printf("Temp = %.3f\r\n", dt);
bouaziz 6:745bea53d3db 48 r = 1- (dt-25)/8.0 ;
bouaziz 6:745bea53d3db 49 flagtemp=0;
bouaziz 6:745bea53d3db 50 }
bouaziz 6:745bea53d3db 51 }
bouaziz 6:745bea53d3db 52 }
chris 4:6df97cb10041 53
bouaziz 6:745bea53d3db 54 // lcd.copy_to_lcd(); // LCD.pixel does not update the lcd
bouaziz 6:745bea53d3db 55 // wait_us(3000);