note : 5 channel flame sensor is used which is mounted on the end effector of the arm,and the robotic arm scan does 180 degree scanning...So experts you are all in here..
a image of code has been attached here so feel free to correct the code. hey listen m also using PCA9685 Servo motor driver to control the robotic arm ,,,i just only need the help in following / tracking of the flame once its get detected ??????#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#define FLAME_SENSOR_PIN A0
#define FIRE_THRESHOLD 200
#define MIN_ANGLE 0
#define MAX_ANGLE 180
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
int servoPin = 0;
void setup() {
Serial.begin(9600);
pwm.begin();
pwm.setPWMFreq(60);
}
void loop() {
for (int angle = MIN_ANGLE; angle <= MAX_ANGLE; angle++) {
pwm.setPWM(servoPin, 0, map(angle, 0, 180, 120, 620));
int flameValue = analogRead(FLAME_SENSOR_PIN);
if (flameValue > FIRE_THRESHOLD) {
Serial.println("Fire detected!");
break;
}
delay(20);
}
}