This demo uses the application board’s I2C temperature sensor to measure the board’s temperature. Pot 1 (blue dial near LCD) is used to adjust a temperature alarm setting. Alarm uses speaker and RGB LED.

Dependencies:   C12832_lcd LM75B mbed

Fork of app-board-LM75B by Chris Styles

Committer:
4180_1
Date:
Sun Sep 22 17:50:35 2013 +0000
Revision:
4:d9371152f77a
Parent:
3:4d612f16ad84
ver 1.0 see https://mbed.org/users/4180_1/notebook/mbed-application-board-hands-on-demos/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:ce7a8546502b 1 #include "mbed.h"
chris 2:9e757151de9b 2 #include "LM75B.h"
chris 2:9e757151de9b 3 #include "C12832_lcd.h"
okano 0:ce7a8546502b 4
4180_1 4:d9371152f77a 5 C12832_LCD lcd; //Graphics LCD
4180_1 4:d9371152f77a 6 LM75B tmp(p28,p27); //I2C Temperature Sensor
4180_1 4:d9371152f77a 7 PwmOut r(p23); //RGB LED with 3 PWM outputs for dimmer control
4180_1 4:d9371152f77a 8 PwmOut g(p24);
4180_1 4:d9371152f77a 9 PwmOut b(p25);
4180_1 4:d9371152f77a 10 PwmOut speaker(p26); //Speaker with PWM driver
4180_1 4:d9371152f77a 11 AnalogIn pot1(p19); //Reads Pot 1 - near LCD
4180_1 4:d9371152f77a 12 AnalogIn pot2(p20); //Reads Pot 2 - near RGB LED
4180_1 4:d9371152f77a 13 Serial pc(USBTX,USBRX); //used for printf to PC over USB
okano 0:ce7a8546502b 14
chris 2:9e757151de9b 15 int main ()
okano 0:ce7a8546502b 16 {
4180_1 4:d9371152f77a 17 float board_temp;
4180_1 4:d9371152f77a 18 float alarm_temp = 0.0;
4180_1 4:d9371152f77a 19 // generate a 800Hz tone using PWM hardware output
4180_1 4:d9371152f77a 20 speaker.period(1.0/800.0); // 800hz period
4180_1 4:d9371152f77a 21 r=1.0; //RGB LED off - PWM 100% duty cycle
4180_1 4:d9371152f77a 22 g=1.0;
4180_1 4:d9371152f77a 23 b=1.0;
okano 0:ce7a8546502b 24
chris 2:9e757151de9b 25 while (1) {
chris 2:9e757151de9b 26 lcd.cls();
4180_1 4:d9371152f77a 27 lcd.locate(0,0); //clears LCD
4180_1 4:d9371152f77a 28 board_temp = tmp; //read temperature
4180_1 4:d9371152f77a 29 lcd.printf("Board Temperature = %.2f\n\r",board_temp);
4180_1 4:d9371152f77a 30 alarm_temp = 50.0 * pot1; //read alarm temp
4180_1 4:d9371152f77a 31 lcd.printf("Temp Alarm Setting = %.2f\n\r",alarm_temp);
4180_1 4:d9371152f77a 32 if(board_temp > alarm_temp) { //check temp for alarm
4180_1 4:d9371152f77a 33 r = 1.0 - pot2; //RGB LED red
4180_1 4:d9371152f77a 34 g = 1.0;
4180_1 4:d9371152f77a 35 speaker = 0.5; //alarm tone using PWM
4180_1 4:d9371152f77a 36 } else {
4180_1 4:d9371152f77a 37 g = 1.0 - pot2; //RGB LED green
4180_1 4:d9371152f77a 38 r = 1.0;
4180_1 4:d9371152f77a 39 speaker = 0.0;
4180_1 4:d9371152f77a 40 }
chris 2:9e757151de9b 41 wait(1.0);
4180_1 4:d9371152f77a 42 pc.printf("%.2f\n\r",board_temp); //send temp to PC
chris 2:9e757151de9b 43 }
okano 0:ce7a8546502b 44 }