TX for Temperature Controlled Fan
Dependencies: 4DGL-uLCD-SE MLX90614 mbed
main.cpp
00001 #include "mbed.h" 00002 #include "mlx90614.h" 00003 #include "uLCD_4DGL.h" 00004 00005 I2C i2c(p28,p27); //sda,scl 00006 00007 MLX90614 IR_thermometer(&i2c); 00008 //setup an MLX90614 using MLX90614 library from 00009 // http://mbed.org/users/aquahika/libraries/MLX90614/lsixz6 00010 00011 DigitalIn sw(p20); 00012 00013 Serial pc(USBTX, USBRX); 00014 00015 Serial xbee1(p9,p10); 00016 00017 uLCD_4DGL uLCD(p13,p14,p11); 00018 00019 DigitalOut myled(LED1); 00020 DigitalOut myled3(LED3);//Create variable for Led 3 on the mbed 00021 00022 int main() { 00023 00024 sw.mode(PullUp); 00025 00026 float current_temp = 0.0; 00027 00028 wait(5.0); 00029 uLCD.printf("Your temp is:"); 00030 while (1) { 00031 wait(1.0); 00032 myled=1; // if led1 on - waiting on I2C 00033 if (IR_thermometer.getTemp(¤t_temp)) { 00034 //gets temperature from sensor via I2C bus 00035 00036 if (sw == 1) { 00037 xbee1.printf("%d \n\r", (int) current_temp); 00038 } 00039 //pc.printf("data %d \n\r", (int) current_temp); 00040 myled=0; 00041 uLCD.text_height(3); 00042 uLCD.text_width(3); 00043 uLCD.locate(1,2); 00044 uLCD.printf("%d C", (int) current_temp); 00045 wait(0.3); 00046 myled3=1; 00047 wait(1.0); 00048 //wait for device to produce next temperature reading 00049 } 00050 } 00051 }
Generated on Tue Jul 19 2022 16:41:29 by 1.7.2