Fan

Dependencies:   DS1820 mbed

Fork of TextLCD by Simon Ford

These files are about how to make a fan which is controlled by the temperature.

Committer:
czr
Date:
Fri May 18 16:20:14 2018 +0000
Revision:
9:9531b96fc3e5
Fan

Who changed what in which revision?

UserRevisionLine numberNew contents of line
czr 9:9531b96fc3e5 1 #include "mbed.h"
czr 9:9531b96fc3e5 2 #include "TextLCD.h"
czr 9:9531b96fc3e5 3 #include "DS1820.h"
czr 9:9531b96fc3e5 4
czr 9:9531b96fc3e5 5 TextLCD lcd(p19,p20,p21,p22,p23,p24);
czr 9:9531b96fc3e5 6 DS1820 probe(p16);
czr 9:9531b96fc3e5 7 PwmOut Fan(p25);
czr 9:9531b96fc3e5 8
czr 9:9531b96fc3e5 9 int main(){
czr 9:9531b96fc3e5 10 Fan.period(0.0001);
czr 9:9531b96fc3e5 11 while(1){
czr 9:9531b96fc3e5 12 probe.convertTemperature(true,DS1820::all_devices);
czr 9:9531b96fc3e5 13 lcd.cls();
czr 9:9531b96fc3e5 14 lcd.printf("The temperature is %.2foC ",probe.temperature());
czr 9:9531b96fc3e5 15 if(probe.temperature()>32){
czr 9:9531b96fc3e5 16 Fan = 1.0;}
czr 9:9531b96fc3e5 17 else if (probe.temperature()>=29){
czr 9:9531b96fc3e5 18 Fan = 0.3;}
czr 9:9531b96fc3e5 19 else {
czr 9:9531b96fc3e5 20 Fan = 0.1;}
czr 9:9531b96fc3e5 21 }
czr 9:9531b96fc3e5 22 }