// Include necessary libraries
#include <SPI.h>

int flamesensor = A5;   // Flame sensor connected to analog pin A5
int LEDR = A2;          // Red LED connected to pin A2
int LEDG = A3;          // Green LED connected to pin A3

void setup() {
  pinMode(flamesensor, INPUT);  // Flame sensor as input
  pinMode(LEDR, OUTPUT);        // Red LED as output
  pinMode(LEDG, OUTPUT);   
  Serial.begin(9600);
}

void loop() {
  int flameValue = digitalRead(flamesensor);  // Read value from flame sensor
  Serial.println(flameValue);
  if(flameValue == 0)  
  {
    digitalWrite(LEDR, HIGH);  
    digitalWrite(LEDG, LOW);   
    delay(1000);              
  }
  else  // No flame detected
  {
    digitalWrite(LEDR, LOW);   
    digitalWrite(LEDG, HIGH);  
    delay(1000);
  }
}
Loading
stm32-bluepill