peltier with 2 fans

Dependencies:   mbed TextLCD

main.cpp

Committer:
redplam
Date:
2014-04-14
Revision:
4:5213bee8158e
Parent:
3:0ef2ced1f02d

File content as of revision 4:5213bee8158e:

#include "mbed.h"
#include "pindefs.h"
#include "led_lights.h"
#include "peltier.h"
#include "peltier_pindefs.h"
#include "TextLCD.h"
#include "pumps.h"
#include "pumps_pindefs.h"
#include "weight.h"
#include "weight_pindefs.h"
#include "DHT.h"

DHT sensor(PTD3,SEN11301P); // Use the SEN11301P sensor

//Serial pc(USBTX, USBRX); // tx, rx
//DigitalOut te1(PTD7);
DigitalOut backlight(PTD6);
float desire_temp;

/*
AnalogIn ain(p19);
DigitalOut led(LED1);

int main() {
    while (1){
        if(ain > 0.3) {
            led = 1;
        } else {
            led = 0;
        }
    }
}
*/


//TextLCD lcd(PTE29, PTE30, PTC12, PTD0, PTD5, PTA13, TextLCD::LCD20x2);   // rs, e, d4-d7 ok
void init (void)
{
    //void pumps(bool pump_1,bool pump_2,bool valve_1,bool humidity_fan_1); pump1-up pump2-down
    pumps(false,false,false,false);

    //void peltier(bool fan_in,bool fan_out,bool cold,bool hot,int pwm_procent);
    peltier(false,false,false,false,0);

}
int main(void)
{
    backlight=1;
    tempinit();
    desire_temp=40;
    /*te1=1;
    te2=1;*/
    //-------------------------
    int err;
    pc.printf("\r\nDHT Test program");
    pc.printf("\r\n******************\r\n");
    wait(1); // wait 1 second for device stable status
    while (1) {
        //  myled = 1;
        err = sensor.readData();
        if (err == 0) {
            pc.printf("Temperature is %4.2f C \r\n",sensor.ReadTemperature(CELCIUS));
            pc.printf("Humidity is %4.2f \r\n",sensor.ReadHumidity());
            if (dsen_temp_in<desire_temp) {
                peltier(true,true,false,true,90);
            }
            if (dsen_temp_in>=desire_temp) {
                peltier(true,true,false,true,0);
            }
        } else
            printf("\r\nErr %i \n",err);

        wait(15);
    }
    //------------------------------
    // while(1) {
    /*     read_weight();
         calc_weight();

         */


    // peltier_auto(30);
    //  led_test();

    // pc.printf("wait20");
    /*
     te2=1;
     wait(1);
      te1=0;
     wait(10);
         peltier(true,true,false,false,10);
        te1=1;
        wait(1);
         te2=0;
         wait(10);
             peltier(true,true,false,false,10);*/

    //wait(1);
    //void peltier(bool fan_in,bool fan_out,bool cold,bool hot,int pwm_procent);
    /*   if (dsen_temp_in<desire_temp) {
           peltier(true,true,false,true,90);
       }
       if (dsen_temp_in>=desire_temp) {
           peltier(true,true,false,true,0);
       }
    */
    /*  wait(10);
      pumps(true,false,false,false);
      wait(2);
      pumps(false,true,true,false);
      wait(2);
      pumps(false,false,false,true);
      wait(2);
      pumps(false,false,false,false);
      wait(20);*/

    // }

}