Flame sensor to A5
Buzzer to Digital 8.
As the code establishes serial communication, you can use the serial monitor to watch the input value to A5 as it changes.
Altering the 600 in the line [ if(val>=600) ] (Reading "if Val is greater or equal to 600") will change the point at which the buzzer sounds.
The code...
int flame=A5; //Define the flame sensor input A5;
int Beep=8; //Buzzer to D8
int val=0;
void setup()
{ pinMode(Beep,OUTPUT);
pinMode(flame,INPUT);
Serial.begin(9600);//set the baudrate to 9600
//this establishes serial communication ;
}
void loop() {
val=analogRead(flame);//analog read the voltage ;
Serial.println(val);
if(val>=600) //if the analog data large than 600 ;
//You can of course change this value... ;
{
digitalWrite(Beep,HIGH);
} else
{ digitalWrite(Beep,LOW); }
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.