readjust library

Dependencies:   C12832_lcd LM75B mbed

Fork of Ex6-1 by mijimy_group

Committer:
mijimy
Date:
Fri Nov 13 02:55:12 2015 +0000
Revision:
1:9ac18dc17a3a
Parent:
0:79f59d830953
readjust library;

Who changed what in which revision?

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