Bonjour,

Ayant reçu de nouveaux détecteurs dont la capteur de flamme, je vous propose mon code pour avis , j'ai rajouté un relais de façon d'avoir plus de puissance suivant la sortie choisie ( gyrophare, sirène ) et temporisation de secondes

Bon la détection ne dépasse pas les 30 cms

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
int led_pin = 13 ;// initializing the pin 9 as the led pin
 
int relaisPin = 7;
int flame_sensor_pin = 8 ;// initializing pin 12 as the sensor output pin
int flame_pin = HIGH ; // state of sensor
 
void setup ( ) {
pinMode(relaisPin, OUTPUT);
  digitalWrite(relaisPin, HIGH);       // ou HIGH si relais actif à 0
 
pinMode ( led_pin , OUTPUT ); // declaring led pin as output pin
pinMode ( flame_sensor_pin , INPUT ); // declaring sensor pin as input pin for Arduino
Serial.begin ( 9600 );// setting baud rate at 9600
}
 
void loop ( ) {
flame_pin = digitalRead ( flame_sensor_pin ) ; // reading from the sensor
 
if (flame_pin == LOW ) // applying condition
{
Serial.println ( " ALARME , ALARME , ALARME " ) ;
digitalWrite ( led_pin , HIGH ) ;// if state is high, then turn high the led
digitalWrite(relaisPin,LOW);
delay(5000);
}
 
else
{
Serial.println ( " PAS DE DETECTION " ) ;
digitalWrite ( led_pin , LOW ) ; // otherwise turn it low
digitalWrite(relaisPin, HIGH);
 
}
}
Merci pour vos avis

Stéphanie