Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo mbed-rtos MQ2 DHT
Revision 1:98989411e334, committed 2019-04-24
- Comitter:
- roycoll
- Date:
- Wed Apr 24 03:04:57 2019 +0000
- Parent:
- 0:872bdbfc6c15
- Child:
- 2:823794c0ec6d
- Commit message:
- Version (Video Presentation)
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Apr 23 15:14:58 2019 +0000
+++ b/main.cpp Wed Apr 24 03:04:57 2019 +0000
@@ -16,7 +16,7 @@
DigitalOut AC(LED3); //Blue on-board LED
DigitalOut led2(LED2); //Green on-board LED
DHT sensor(D4, DHT11); //Temperature and humidity sensor
- PwmOut PWM1(A4); //pin A4 == pin A5
+ PwmOut PWM1(D11); //pin A4 == pin A5
Serial pc(USBTX, USBRX);
MQ2 mq2(A1); // Analog Port to read from MQ2_gas sensor
Servo myservo(A5); //Servo signal to simulate a window opening or closing
@@ -83,14 +83,18 @@
}
}
if((sw2 == 0) && (win == closed)){
- for(; p<1.0 && sw2 == 0; p += 0.05) { //**Servo simulates opening a window if CarbonMonoxide level inside becomes too high while occupant is present
+ //for(; p<1.0 && sw2 == 0; p += 0.05) { //**Servo simulates opening a window if CarbonMonoxide level inside becomes too high while occupant is present
+ while(p<=1.0 && sw2 ==0){
+ p=p+0.05;
myservo = p;
wait(0.05);
}
win = open;
}
else if((win == open) && (sw2 == 0)){
- for(; p>0 && sw2 ==0; p -= 0.05) {
+ //for(; p>0 && sw2 ==0; p -= 0.05) {
+ while(p>=0.0 && sw2 ==0){
+ p=p-0.05;
myservo = p;
wait(0.05);
}
@@ -106,7 +110,7 @@
AC = !on;
}
if(Heat == !on || AC == !on) {
- fan = 4;}
+ fan = 10;}
else if(Heat == !off && AC == !off){
fan = off;}
if(Occupant == 1){
@@ -123,14 +127,16 @@
Green = 1; //
Buzz = !on;
if(win == closed){
- for(; p<1.0; p += 0.05) { //**Servo simulates opening a window if CarbonMonoxide level inside becomes too high while occupant is present
+ //for(; p<1.0; p += 0.05) { //**Servo simulates opening a window if CarbonMonoxide level inside becomes too high while occupant is present
+ while(p<=1.0){
+ p=p+0.05;
myservo = p;
wait(0.05);
}
win = open;
}
- if(win==open && Engine == on){
- Engine = off;}
+ // if(win == open && Engine == on){
+ // Engine = off;}
} //
else if(MQ2_data.co >=50 && MQ2_data.co <= 300)
{ //wait(.5); //
@@ -145,22 +151,26 @@
Green = 0;
Buzz = !off;
}
- if(f >= 80 || f <= 70) //Temperature from DHT
+ if(f >= 90 || f <= 50) //Temperature from DHT
{ Engine = on; //x = 10;
- fan = 4;
- if(f>=80){
+ fan = 10;
+ if(f>=90){
AC = !on;Heat=!off;
if(win == closed){ //**Servo simulates opening a window if Temperature inside becomes too high while occupant is present
- for(; p<1.0; p += 0.05) {
+ //for(; p<1.0; p += 0.05) {
+ while(p<=1.0){
+ p=p+0.05;
myservo = p;
wait(0.05);
}
win = open;
}
- else if(f<=70)
+ else if(f<=50)
{ Heat = !on;AC=!off;
if(win == open){
- for(; p>0; p -= 0.05) {
+ //for(; p>0.0; p -= 0.05) {
+ while(p>=0.0){
+ p=p-0.05;
myservo = p;
wait(0.05);
}
@@ -169,14 +179,14 @@
}
}
}
- else if(Occupant == 0 && AC == !on){
+ /* else if(Occupant == 0 && AC == !on){
Engine = on; //x = 10;
fan= 4;
}
else if(Occupant == 0 && Heat == !on){
Engine = on; //x = 10;
fan=4;
- } //**DC motor sig end
+ } */
}
}
}