Skip to content

Instantly share code, notes, and snippets.

@fxprime
Created November 2, 2019 04:07
Show Gist options
  • Save fxprime/436bdccd30e636694a2ebf714ce434d6 to your computer and use it in GitHub Desktop.
Save fxprime/436bdccd30e636694a2ebf714ce434d6 to your computer and use it in GitHub Desktop.
Flame sensor module KY-026
int led = 13; // define the LED pin
int digitalPin = 2; // KY-026 digital interface
int analogPin = A0; // KY-026 analog interface
int digitalVal; // digital readings
int analogVal; //analog readings
void setup()
{
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
//pinMode(analogPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// Read the digital interface
digitalVal = digitalRead(digitalPin);
if(digitalVal == HIGH) // if flame is detected
{
digitalWrite(led, HIGH); // turn ON Arduino's LED
}
else
{
digitalWrite(led, LOW); // turn OFF Arduino's LED
}
// Read the analog interface
analogVal = analogRead(analogPin);
Serial.println(analogVal); // print analog value to serial
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment