update
Dependencies: Air_Quality DHT mbed-src
Fork of mbed_Wiznet_W7500 by
Revision 2:37c5a8883978, committed 2015-08-12
- Comitter:
- M_J
- Date:
- Wed Aug 12 04:52:58 2015 +0000
- Parent:
- 1:f9339d95123d
- Commit message:
- update
Changed in this revision
Air_Quality.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f9339d95123d -r 37c5a8883978 Air_Quality.lib --- a/Air_Quality.lib Tue Aug 11 14:43:36 2015 +0000 +++ b/Air_Quality.lib Wed Aug 12 04:52:58 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/ysy00700/code/Air_Quality/#7653022b71cb +https://developer.mbed.org/users/M_J/code/Air_Quality/#3d804fbaa44d
diff -r f9339d95123d -r 37c5a8883978 main.cpp --- a/main.cpp Tue Aug 11 14:43:36 2015 +0000 +++ b/main.cpp Wed Aug 12 04:52:58 2015 +0000 @@ -6,8 +6,8 @@ int current_quality = -1; PinName analogPin = A0; -DHT sensor(D3, DHT11); -InterruptIn motion(D2); +DHT sensor(D4, DHT11); +InterruptIn motion(D3); AnalogIn luminance(A1); DigitalOut led_R(LED_RED); @@ -38,54 +38,30 @@ airqualitysensor.init(analogPin, AirQualityInterrupt); - int cnt = 0; motion.rise(&irq_handler); while(1) { - wait(0.1); + wait(0.3); error = sensor.readData(); if (0 == error) { hum = sensor.ReadHumidity(); cel = sensor.ReadTemperature(CELCIUS); - printf(" 1. Humidity : %4.2f\r\n\n", hum); - printf(" 2. Temperature in Celcius : %2.2f\r\n\n", cel); - - { - if (hum > 70) { // if celcius is higher than 28, LED_RED on. - led_R = 0; // LED_RED on - led_B = 1; // LED_BLUE off - } - else{ - led_R = 1; // LED_RED off - led_B = 0; // LED_BLUE on - } - } - { - if(cel > 28) { // if celcius is higher than 28, LED_RED on. - led_R = 0; // LED_RED on - led_B = 1; // LED_BLUE off - } - else { - led_R = 1; // LED_RED off - led_B = 0; // LED_BLUE on - } - } + printf("1. Humidity : %4.2f\r\n\n", hum); + wait(0.3); + printf("2. Temperature in Celcius : %2.2f\r\n\n", cel); + wait(0.3); } else { - printf("Error : %d\n", error); + //printf("Error : %d\n", error); } if(motion_detected) { - cnt++; motion_detected = 0; - /*led_R = 1; - led_G = 1; - led_B = 1;*/ - - printf("3. Something move%d\r\n\n", cnt); - wait(0.1); + + printf("3. Something move!\r\n\n"); + wait(0.3); } if(luminance.read()){ @@ -97,124 +73,24 @@ led_R=1; led_G=1; led_B=1;} // led off printf("4. Luminance: %f\r\n\n", luminance.read()); - wait(0.1); + wait(0.3); } else { led_R=0; led_G=0; led_B=0; // white LED on printf("4. Luminance: %f\r\n\n", luminance.read()); - wait(0.1); + wait(0.3); } //air quality sensor current_quality=airqualitysensor.slope(); if (current_quality >= 0) { // if a valid data returned. - if (current_quality == 0){ - printf("5. High pollution! Force signal active\n\r\n"); - // led1 = 0; - // led2 = 1; - } - else if (current_quality == 1){ - printf("5. High pollution!\n\r\n"); - // led1 = 0; - // led2 = 1; - } - else if (current_quality == 2){ - printf("5. Low pollution!\n\n\r"); - // led1 = 0; - // led2 = 1; - } - else if (current_quality == 3){ - printf("5. Fresh air\n\r\n"); - // led1 = 1; - // led2 = 0; - } + if (current_quality == 0) + printf(" High pollution! Force signal active\n\r\n"); + else if (current_quality == 1) + printf(" High pollution!\n\r\n"); + else if (current_quality == 2) + printf(" Low pollution!\n\n\r"); + else if (current_quality == 3) + printf(" Fresh air!\n\r\n"); } - } } -/* -AnalogIn luminance(A0); -InterruptIn motion(D2); - -DigitalOut RED(LED1, 1); -DigitalOut GREEN(LED2, 1); -DigitalOut BLUE(LED3, 1); - -int motion_detected = 0; - -void irq_handler(void) -{ - motion_detected = 1; -} - -int main() -{ - int cnt = 0; - motion.rise(&irq_handler); - - while (true) { - - //grove motion sensor - if(motion_detected) { - cnt++; - motion_detected = 0; - RED = 0; - GREEN = 1; - BLUE = 1; - wait(1); - printf("Something move%d\r\n", cnt); - } - - //luminance sensor - if(luminance.read()){ - - if(0.1<=luminance.read()&&luminance.read()<=0.3){ - RED=0; GREEN=0; BLUE=1;} // yellow LED on - - else{ - RED=1; GREEN=1; BLUE=1;} // led off - - printf("Luminance: %f\r\n", luminance.read()); - wait(0.5f); - } - else { - RED=0; GREEN=0; BLUE=0; // white LED on - printf("Luminance: %f\r\n", luminance.read()); - wait(0.5f); - } - - } -}*/ -/* -InterruptIn motion(D2); - -DigitalOut RED(LED1, 1); -DigitalOut GREEN(LED2, 1); -DigitalOut BLUE(LED3, 1); - -int motion_detected = 0; - -void irq_handler(void) -{ - motion_detected = 1; -} - -int main() -{ - int cnt = 0; - motion.rise(&irq_handler); - - while (true) { - - //grove motion sensor - if(motion_detected) { - cnt++; - motion_detected = 0; - RED = 0; - GREEN = 1; - BLUE = 1; - wait(1); - printf("Something move%d\r\n", cnt); - } - - } -}*/ \ No newline at end of file