Project Autus - Automated Plant Chamber

Dependencies:   TextLCD mbed

Fork of keypad_test by Plamen Totev

Autus

This is the codebase accompanying the project Autus.

Autus is an automated growth chamber for plants.

Features

Control Humidity inside chamber wrt to external humidity. Control Temperature inside chamber. ( Peltier Heaters/Coolers ) Water and shower plants. Control soil humidity. Monitor water tanks level (Load Cell) /media/uploads/umairaftab/frdm_-_new_page1.png

Code Base Features

Fixed timing and CRC for DHT-11 Sensor. Fixed OneWire bug for ds18b20

Cyclic Executive Scheduler with Priority. Async IPC framework for PC App over bluetooth

Fake RTC systick, I was having some trouble with the on board rtc.

/media/uploads/umairaftab/download.png

led_light/led_lights.cpp

Committer:
umairaftab
Date:
2014-04-14
Revision:
57:7ab93ed49b70
Parent:
37:892872c3fa96

File content as of revision 57:7ab93ed49b70:

#include "mbed.h"
#include "led_lights.h"
unsigned int led_red_pulsewidth;
unsigned int led_green_pulsewidth;
unsigned int led_blue_pulsewidth;
unsigned int led_period =1000;
unsigned int led_pulsewidth = 0;
unsigned int led_step = 10;

int MAX_RED_LIGHT = 100;
int MAX_BLUE_LIGHT = 100;
int MAX_GREEN_LIGHT = 100;

bool led_set_flag= false;

unsigned int pwm_blue_led(int brightness )
{
    if (brightness==1) {
        led_blue_pulsewidth=led_blue_pulsewidth+led_step;
        led_blue.pulsewidth_us(led_blue_pulsewidth);
    };
    if (brightness==0) {
        led_blue_pulsewidth=led_blue_pulsewidth-led_step;
        led_blue.pulsewidth_us(led_blue_pulsewidth);
    };
    return led_blue_pulsewidth;
}
unsigned int pwm_green_led(int brightness)
{
    if (brightness==1) {
        led_green_pulsewidth=led_green_pulsewidth+led_step;
        led_green.pulsewidth_us(led_green_pulsewidth);
    }
    if (brightness==0) {
        led_green_pulsewidth=led_green_pulsewidth-led_step;
        led_green.pulsewidth_us(led_green_pulsewidth);
    }
    return led_green_pulsewidth;
}
unsigned int pwm_red_led(int brightness)
{
    if (brightness==1) {
        led_red_pulsewidth=led_red_pulsewidth+led_step;
        led_red.pulsewidth_us(led_red_pulsewidth);
    }
    if (brightness==0) {
        led_red_pulsewidth=led_red_pulsewidth-led_step;
        led_red.pulsewidth_us(led_red_pulsewidth);
    }
    return led_red_pulsewidth;
}

void led_test(void){
    led_blue.period_us(led_period);
    led_blue_pulsewidth=led_pulsewidth;
    for (int i=1; i<=MAX_BLUE_LIGHT; i++) {
        pwm_blue_led(1);
        wait (0.1);
    }
    for (int i=1; i<=MAX_BLUE_LIGHT; i++) {
        pwm_blue_led(0);
        wait (0.1);
    }
    led_blue_pulsewidth=10;    // set to 0
    pwm_blue_led(0);           // set to 0

    led_red.period_us(led_period);
    led_red_pulsewidth=led_pulsewidth;
    for (int i=1; i<=MAX_RED_LIGHT; i++) {
        pwm_red_led(1);
        wait (0.1);
    }
    for (int i=1; i<=MAX_RED_LIGHT; i++) {
        pwm_red_led(0);
        wait (0.1);
    }
    led_red_pulsewidth=10;    // set to 0
    pwm_red_led(0);           // set to 0
    
    led_green.period_us(led_period);
    led_green_pulsewidth=led_pulsewidth;
    for (int i=1; i<=MAX_GREEN_LIGHT; i++) {
        pwm_green_led(1);
        wait (0.1);
    }
    for (int i=1; i<=MAX_GREEN_LIGHT; i++) {
        pwm_green_led(0);
        wait (0.1);
    }
    led_green_pulsewidth=10;    // set to 0
    pwm_green_led(0);           // set to 0
}

void set_leds(){
    
    //BLUE
    led_blue.period_us(led_period);
    led_blue_pulsewidth=led_pulsewidth;
    for (int i=1; i<=MAX_BLUE_LIGHT; i++) {
        pwm_blue_led(1);
        wait (0.1);
    }
    //RED
    led_red.period_us(led_period);
    led_red_pulsewidth=led_pulsewidth;
    for (int i=1; i<=MAX_RED_LIGHT; i++) {
        pwm_red_led(1);
        wait (0.1);
    }
    //GREEN
    led_green.period_us(led_period);
    led_green_pulsewidth=led_pulsewidth;
    for (int i=1; i<=MAX_GREEN_LIGHT; i++) {
        pwm_green_led(1);
        wait (0.1);
    }
    led_set_flag = true;
    
}
void turn_off_leds(){
        
    led_red_pulsewidth=10;    // set to 0
    pwm_red_led(0);        
    led_blue_pulsewidth=10;    // set to 0
    pwm_blue_led(0);           // set to 0
    
    led_green_pulsewidth=10;    // set to 0
    pwm_green_led(0);  
}