#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#define IR_SENSOR_PIN 32
#define FLAME_SENSOR_PIN 33
#define LED1_PIN 25
#define LED2_PIN 26
#define THRESHOLD 2000
void sensor_task(void *pvParameter) {
int ir_reading = 0;
int flame_reading = 0;
while (1) {
// Read IR sensor
ir_reading = analogRead(IR_SENSOR_PIN);
// Read flame sensor
flame_reading = analogRead(FLAME_SENSOR_PIN);
// Check if readings exceed thresholds
if (ir_reading > THRESHOLD || flame_reading > THRESHOLD) {
// Turn on LEDs
digitalWrite(LED1_PIN, HIGH);
digitalWrite(LED2_PIN, HIGH);
} else {
// Turn off LEDs
digitalWrite(LED1_PIN, LOW);
digitalWrite(LED2_PIN, LOW);
}
// Wait for 100ms before taking the next reading
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}
int main() {
// Create the sensor task
xTaskCreate(sensor_task, "Sensor Task", 2048, NULL, 1, NULL);
// Start the scheduler
vTaskStartScheduler();
return 0;
}