Код на проекта
int led_pin = 13 ;// initializing the pin 13 as the led pin
int flame_sensor_pin = 2 ;// initializing pin 7 as the sensor output pin
int flame_pin = HIGH ; // state of sensor
int BUZZER = 8;
void setup ( ) {
pinMode ( led_pin , OUTPUT ); // declaring led pin as output pin
pinMode ( flame_sensor_pin , INPUT ); // declaring sensor pin as input pin for Arduino
pinMode(BUZZER, OUTPUT);
}
flame_pin = digitalRead ( flame_sensor_pin ) ; // reading from the sensor
void loop ( ) {
if (flame_pin == LOW ) // applying condition
{
digitalWrite ( led_pin , HIGH ) ;// if state is high, then turn high the led
digitalWrite(BUZZER, HIGH);
}
else
{
digitalWrite ( led_pin , LOW ) ; // otherwise turn it low
digitalWrite(BUZZER, LOW);
}
}