Commit cd70a87a authored by Gayan Kavinda Gamlath's avatar Gayan Kavinda Gamlath 😂

dust_sensor

parent b7c3d438
int measurePin = A7;
int ledPower = 11;
unsigned int samplingTime = 280; /*the same as ints in that they store a 2 byte value*/
unsigned int deltaTime = 40; /*Calculate time taken by loop.*/
unsigned int sleepTime = 9680; /*Pauses the program for the amount of time (in milliseconds) specified as parameter. (There are 1000 milliseconds in a second.)*/
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
......@@ -3,21 +3,25 @@ const int flamepin=A5;
const int buzpin=11;
const int threshold=200;// sets threshold value for flame sensor
int flamesensvalue=0; // initialize flamesensor reading
void setup() {
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
pinMode(flamepin,INPUT);
pinMode(buzpin,OUTPUT);
}
void loop() {
flamesensvalue=analogRead(flamepin); // reads analog data from flame sensor
if (flamesensvalue<=threshold) { // compares reading from flame sensor with the threshold value
digitalWrite(ledpin,HIGH); //turns on led and buzzer
tone(buzpin,100);
delay(700); //stops program for 1 second
flamesensvalue=analogRead(flamepin); // reads analog data from flame sensor
if (flamesensvalue<=threshold) { // compares reading from flame sensor with the threshold value
digitalWrite(ledpin,HIGH); //turns on led and buzzer
tone(buzpin,100);
delay(700); //stops program for 1 second
}
else{
digitalWrite(ledpin,LOW); //turns led off led and buzzer
noTone(buzpin);
}
digitalWrite(ledpin,LOW); //turns led off led and buzzer
noTone(buzpin);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment