> For the complete documentation index, see [llms.txt](https://guides.mccaskeyrobotics.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guides.mccaskeyrobotics.org/arduino/flame-sensor-with-alarm.md).

# Flame Sensor with Alarm

![Flame Sensor Wired Up](https://lh5.googleusercontent.com/qQ_MD8c7bU7ZlGIwRU512e7A9bPokkVPhZqT93aqmaDy7jD3rRUf3KQUyN145lZxOQNXQXJh_RbVVi706ZcoQv4kHAkRS7nTNUZWQcDT0DZCdZo-pvAEbTLaGqWCyPuCi5NbKpYhk5UhzzPbaA)

#### Wiring for the Flame Sensor

| Arduino | Flame Sensor |
| ------- | ------------ |
| GD      | G            |
| A0      | A0           |
| 5V      | +            |

#### Wiring for the Buzzer

| Arduino | Buzzer |
| ------- | ------ |
| 13      | +      |
| GND     | -      |

#### Code:

```cpp
int sensorPin = A0; // select the input pin for the potentiometer
int buzzer = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor

void setup()
{
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);
  if (sensorValue < 40) {
    tone(buzzer, 1000);
  }
  else {
    noTone(buzzer);
  }
}


```
