Advertisement
Zeinab_Hamdy

Flame Sensor

Oct 19th, 2024 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. const int flameSensorPin = 2;
  2.  
  3. void setup() {
  4.     Serial.begin(9600);
  5.     pinMode(flameSensorPin, INPUT);
  6. }
  7.  
  8. void loop() {
  9.     int flameValue = digitalRead(flameSensorPin);
  10.    
  11.    
  12.     Serial.print("Flame Value: ");
  13.     Serial.println(flameValue);
  14.    
  15.  
  16.     if (flameValue == LOW) { // LOW => flame is detected
  17.         Serial.println("Flame Detected!");
  18.     } else {
  19.         Serial.println("No Flame Detected.");
  20.     }
  21.    
  22.     delay(2000);
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement