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.

main.cpp

Committer:
czr
Date:
2018-05-18
Revision:
9:9531b96fc3e5

File content as of revision 9:9531b96fc3e5:

#include "mbed.h"
#include "TextLCD.h"
#include "DS1820.h"

TextLCD lcd(p19,p20,p21,p22,p23,p24);
DS1820 probe(p16);
PwmOut Fan(p25);

int main(){
    Fan.period(0.0001);
    while(1){
        probe.convertTemperature(true,DS1820::all_devices);
        lcd.cls();
        lcd.printf("The temperature is %.2foC ",probe.temperature());
        if(probe.temperature()>32){
            Fan = 1.0;}
        else if (probe.temperature()>=29){
            Fan = 0.3;}
        else {
            Fan = 0.1;}
    }
    }