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; ...@@ -3,21 +3,25 @@ const int flamepin=A5;
const int buzpin=11; const int buzpin=11;
const int threshold=200;// sets threshold value for flame sensor const int threshold=200;// sets threshold value for flame sensor
int flamesensvalue=0; // initialize flamesensor reading int flamesensvalue=0; // initialize flamesensor reading
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
pinMode(ledpin,OUTPUT); pinMode(ledpin,OUTPUT);
pinMode(flamepin,INPUT); pinMode(flamepin,INPUT);
pinMode(buzpin,OUTPUT); pinMode(buzpin,OUTPUT);
} }
void loop() { void loop() {
flamesensvalue=analogRead(flamepin); // reads analog data from flame sensor flamesensvalue=analogRead(flamepin); // reads analog data from flame sensor
if (flamesensvalue<=threshold) { // compares reading from flame sensor with the threshold value if (flamesensvalue<=threshold) { // compares reading from flame sensor with the threshold value
digitalWrite(ledpin,HIGH); //turns on led and buzzer
tone(buzpin,100); digitalWrite(ledpin,HIGH); //turns on led and buzzer
delay(700); //stops program for 1 second tone(buzpin,100);
delay(700); //stops program for 1 second
} }
else{ else{
digitalWrite(ledpin,LOW); //turns led off led and buzzer digitalWrite(ledpin,LOW); //turns led off led and buzzer
noTone(buzpin); 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