温度センサLM75Bとキャラクタ液晶AQM0802Aをmbed LPC1114FN28に繋げて、温度をキャラク液晶に出力するプログラム

Dependencies:   LM75B SB1602E mbed

Committer:
jksoft
Date:
Sun May 15 11:38:21 2016 +0000
Revision:
0:34ef48e4a588
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:34ef48e4a588 1 #include "mbed.h"
jksoft 0:34ef48e4a588 2 #include "LM75B.h"
jksoft 0:34ef48e4a588 3 #include "SB1602E.h"
jksoft 0:34ef48e4a588 4
jksoft 0:34ef48e4a588 5 //Create an LM75B object at the default address (ADDRESS_0)
jksoft 0:34ef48e4a588 6 LM75B sensor(dp5, dp27);
jksoft 0:34ef48e4a588 7 SB1602E lcd( dp5, dp27);
jksoft 0:34ef48e4a588 8
jksoft 0:34ef48e4a588 9 int main()
jksoft 0:34ef48e4a588 10 {
jksoft 0:34ef48e4a588 11 //Try to open the LM75B
jksoft 0:34ef48e4a588 12 if (sensor.open()) {
jksoft 0:34ef48e4a588 13 printf("Device detected!\n");
jksoft 0:34ef48e4a588 14
jksoft 0:34ef48e4a588 15 while (1) {
jksoft 0:34ef48e4a588 16 lcd.clear();
jksoft 0:34ef48e4a588 17 //Print the current temperature
jksoft 0:34ef48e4a588 18 lcd.printf(0,"Tmp:%.1f\n", (float)sensor);
jksoft 0:34ef48e4a588 19
jksoft 0:34ef48e4a588 20 //Sleep for 0.5 seconds
jksoft 0:34ef48e4a588 21 wait(0.5);
jksoft 0:34ef48e4a588 22 }
jksoft 0:34ef48e4a588 23 } else {
jksoft 0:34ef48e4a588 24 error("Device not detected!\n");
jksoft 0:34ef48e4a588 25 }
jksoft 0:34ef48e4a588 26 }