Go Down

Topic: alarm system, problem smoke sensor (Read 478 times) previous topic - next topic

pengocha

Hi all,

i'm working on my alarm system. What i have working so far is:
- activate ultrasonic sensor with password
- notify pushingbox when alarm is (de)active
- smoke detector when alarm is off

What i'm trying to do is get my smoke sensor also working when the alarm is active but i can't figure out where to add the code to do it.

Code smoke sensor to add:
Code: [Select]
//smoke loop starts here
    activateAlarm = true;
    int analogSensor = analogRead(pinDevid1);
    Serial.print("pinDevid1: ");
    Serial.println(analogSensor);
   // Checks if it has reached the threshold value
   if (analogSensor > sensorThres)
    {
    Serial.println("rook");
    tone(buzzer, 1000, 200);
   }
    else
    {
    Serial.println("geen rook");
    noTone(buzzer);
    }
//smoke loop ends



Complete Code (with smoke sensor added and working while alarm is off) is added in attachment.


Thanks for the advice !

PaulS

Code: [Select]
//smoke loop starts here
What the hell is a "smoke loop"?

Did you read the stickies at the top of the forum? Did you see the part where it says POST ALL OF YOUR CODE? Did you think that, for some reason, that did not apply to you? I can assure that is DOES.
The art of getting good answers lies in asking good questions.

pengocha

#2
Feb 16, 2017, 01:43 pm Last Edit: Feb 16, 2017, 01:49 pm by pengocha
The code i pasted is the part that needs to be added when the alarm is running.
The entire project code was to long to paste so i've added it in attach...

PaulS

Which Arduino are you running that code on?

Code: [Select]
              if (keypressed == '0' || keypressed == '1' || keypressed == '2' || keypressed == '3' ||
                  keypressed == '4' || keypressed == '5' || keypressed == '6' || keypressed == '7' ||
                  keypressed == '8' || keypressed == '9' ) {

Do you really like to type?

Code: [Select]
   if(keypressed >= '0' && keypressed <= '9')
Same answer; far less typing; just as easy to understand.

All that crap with getting input from the keypad belongs in a function, not in loop().

Quote
What i'm trying to do is get my smoke sensor also working when the alarm is active but i can't figure out where to add the code to do it.
Your smoke sensor works all the time. On every pass through loop(), you get data from it. I don't understand what the issue is with using that data anywhere in loop().
The art of getting good answers lies in asking good questions.

Go Up