Created
November 2, 2019 04:07
-
-
Save fxprime/436bdccd30e636694a2ebf714ce434d6 to your computer and use it in GitHub Desktop.
Flame sensor module KY-026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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