Detection OK, changement couleur LED et alarme sonore OK
This commit is contained in:
parent
4e0cfbe12f
commit
57de082e7e
102
.gitignore
vendored
102
.gitignore
vendored
@ -1,34 +1,70 @@
|
|||||||
# ---> C++
|
app/bin/
|
||||||
# Prerequisites
|
app/pde.jar
|
||||||
*.d
|
build/macosx/work/
|
||||||
|
arduino-core/bin/
|
||||||
# Compiled Object files
|
arduino-core/arduino-core.jar
|
||||||
*.slo
|
hardware/arduino/bootloaders/caterina_LUFA/Descriptors.o
|
||||||
*.lo
|
hardware/arduino/bootloaders/caterina_LUFA/Descriptors.lst
|
||||||
*.o
|
hardware/arduino/bootloaders/caterina_LUFA/Caterina.sym
|
||||||
*.obj
|
hardware/arduino/bootloaders/caterina_LUFA/Caterina.o
|
||||||
|
hardware/arduino/bootloaders/caterina_LUFA/Caterina.map
|
||||||
# Precompiled Headers
|
hardware/arduino/bootloaders/caterina_LUFA/Caterina.lst
|
||||||
*.gch
|
hardware/arduino/bootloaders/caterina_LUFA/Caterina.lss
|
||||||
*.pch
|
hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
|
||||||
|
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
|
||||||
# Compiled Dynamic libraries
|
hardware/arduino/bootloaders/caterina_LUFA/.dep/
|
||||||
*.so
|
build/*.zip
|
||||||
*.dylib
|
build/*.tar.bz2
|
||||||
*.dll
|
build/windows/work/
|
||||||
|
build/windows/*.zip
|
||||||
# Fortran module files
|
build/windows/*.tgz
|
||||||
*.mod
|
build/windows/*.tar.bz2
|
||||||
*.smod
|
build/windows/libastylej*
|
||||||
|
build/windows/liblistSerials*
|
||||||
# Compiled Static libraries
|
build/windows/arduino-*.zip
|
||||||
*.lai
|
build/windows/dist/*.tar.gz
|
||||||
*.la
|
build/windows/dist/*.tar.bz2
|
||||||
*.a
|
build/windows/launch4j-*.tgz
|
||||||
*.lib
|
build/windows/launch4j-*.zip
|
||||||
|
build/windows/launcher/launch4j
|
||||||
# Executables
|
build/windows/WinAVR-*.zip
|
||||||
*.exe
|
build/macosx/arduino-*.zip
|
||||||
*.out
|
build/macosx/dist/*.tar.gz
|
||||||
*.app
|
build/macosx/dist/*.tar.bz2
|
||||||
|
build/macosx/*.tar.bz2
|
||||||
|
build/macosx/libastylej*
|
||||||
|
build/macosx/appbundler*.jar
|
||||||
|
build/macosx/appbundler*.zip
|
||||||
|
build/macosx/appbundler
|
||||||
|
build/macosx/appbundler-1.0ea-arduino?
|
||||||
|
build/macosx/appbundler-1.0ea-arduino*.zip
|
||||||
|
build/macosx/appbundler-1.0ea-upstream*.zip
|
||||||
|
build/linux/work/
|
||||||
|
build/linux/dist/*.tar.gz
|
||||||
|
build/linux/dist/*.tar.bz2
|
||||||
|
build/linux/*.tgz
|
||||||
|
build/linux/*.tar.xz
|
||||||
|
build/linux/*.tar.bz2
|
||||||
|
build/linux/*.zip
|
||||||
|
build/linux/libastylej*
|
||||||
|
build/linux/liblistSerials*
|
||||||
|
build/shared/arduino-examples*
|
||||||
|
build/shared/reference*.zip
|
||||||
|
build/shared/Edison*.zip
|
||||||
|
build/shared/Galileo*.zip
|
||||||
|
build/shared/WiFi101-Updater-ArduinoIDE-Plugin*.zip
|
||||||
|
test-bin
|
||||||
|
*.iml
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
.directory
|
||||||
|
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
|
||||||
|
avr-toolchain-*.zip
|
||||||
|
/app/nbproject/private/
|
||||||
|
/arduino-core/nbproject/private/
|
||||||
|
/app/build/
|
||||||
|
/arduino-core/build/
|
||||||
|
|
||||||
|
manifest.mf
|
||||||
|
nbbuild.xml
|
||||||
|
nbproject
|
30
AlarmeESP32.ino
Normal file
30
AlarmeESP32.ino
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#include <ctrlLed.h>
|
||||||
|
#include <FireBaseHandler.h>
|
||||||
|
#include <ctrlSpeaker.h>
|
||||||
|
#include <ctrlRfid.h>
|
||||||
|
#include <branchements.h>
|
||||||
|
|
||||||
|
volatile bool motionDetected = false;
|
||||||
|
|
||||||
|
void IRAM_ATTR onMotionDetected() {
|
||||||
|
motionDetected = true; // Flag à traiter dans loop()
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
pinMode(A2, INPUT);
|
||||||
|
pinMode(D2, OUTPUT);
|
||||||
|
attachInterrupt(digitalPinToInterrupt(A2), onMotionDetected, RISING);
|
||||||
|
|
||||||
|
blinkSlowGreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if(motionDetected){
|
||||||
|
Serial.println("Mouvement détecté !");
|
||||||
|
blinkFastRed();
|
||||||
|
startSirene();
|
||||||
|
}
|
||||||
|
updateLed();
|
||||||
|
updateSirene();
|
||||||
|
}
|
||||||
|
|
0
FirebaseHandler.h
Normal file
0
FirebaseHandler.h
Normal file
14
branchements.h
Normal file
14
branchements.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#define A0 26
|
||||||
|
#define A1 25
|
||||||
|
#define A2 34
|
||||||
|
#define D2 39
|
||||||
|
#define A4 36
|
||||||
|
#define A5 4
|
||||||
|
#define D2 14
|
||||||
|
#define D3 32
|
||||||
|
#define D4 15
|
||||||
|
#define D5 33
|
||||||
|
#define RX 16
|
||||||
|
#define TX 17
|
||||||
|
#define SCL 22
|
||||||
|
#define SDA 23
|
64
ctrlLed.h
Normal file
64
ctrlLed.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#include <ChainableLED.h>
|
||||||
|
#include <branchements.h>
|
||||||
|
|
||||||
|
#define NUM_LEDS 1
|
||||||
|
|
||||||
|
ChainableLED leds(D4, D5, NUM_LEDS);
|
||||||
|
|
||||||
|
enum LedState { OFF, FAST_RED, SLOW_RED, SLOW_GREEN };
|
||||||
|
LedState currentState = OFF;
|
||||||
|
|
||||||
|
unsigned long previousMillis = 0;
|
||||||
|
int blinkInterval = 0;
|
||||||
|
bool ledOn = false;
|
||||||
|
|
||||||
|
void updateLed() {
|
||||||
|
unsigned long currentMillis = millis();
|
||||||
|
|
||||||
|
if (currentState == OFF) {
|
||||||
|
leds.setColorRGB(0, 0, 0, 0); // Éteindre la LED
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentMillis - previousMillis >= blinkInterval) {
|
||||||
|
previousMillis = currentMillis;
|
||||||
|
ledOn = !ledOn; // Alterner entre ON et OFF
|
||||||
|
|
||||||
|
switch (currentState) {
|
||||||
|
case FAST_RED:
|
||||||
|
leds.setColorRGB(0, ledOn ? 255 : 0, 0, 0);
|
||||||
|
blinkInterval = 200; // Alternance rapide
|
||||||
|
break;
|
||||||
|
case SLOW_RED:
|
||||||
|
leds.setColorRGB(0, ledOn ? 255 : 0, 0, 0);
|
||||||
|
blinkInterval = ledOn ? 200 : 1300; // Court allumage, longue extinction
|
||||||
|
break;
|
||||||
|
case SLOW_GREEN:
|
||||||
|
leds.setColorRGB(0, 0, ledOn ? 255 : 0, 0);
|
||||||
|
blinkInterval = ledOn ? 200 : 800; // Court allumage, longue extinction
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void blinkFastRed() {
|
||||||
|
currentState = FAST_RED;
|
||||||
|
blinkInterval = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
void blinkSlowRed() {
|
||||||
|
currentState = SLOW_RED;
|
||||||
|
blinkInterval = 200; // Premier allumage court
|
||||||
|
}
|
||||||
|
|
||||||
|
void blinkSlowGreen() {
|
||||||
|
currentState = SLOW_GREEN;
|
||||||
|
blinkInterval = 200; // Premier allumage court
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearLed() {
|
||||||
|
currentState = OFF;
|
||||||
|
leds.setColorRGB(0, 0, 0, 0);
|
||||||
|
}
|
0
ctrlRfid.h
Normal file
0
ctrlRfid.h
Normal file
34
ctrlSpeaker.h
Normal file
34
ctrlSpeaker.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
// Fréquences sirène
|
||||||
|
int sirenTab[] = {1516, 1702};
|
||||||
|
|
||||||
|
bool sireneOn = false;
|
||||||
|
unsigned long previousMillisAlarm = 0; // Stocke le temps écoulé
|
||||||
|
unsigned long interval = 250; // Intervalle pour changer de fréquence
|
||||||
|
int sirenIndex = 0; // Indice de la fréquence actuelle
|
||||||
|
|
||||||
|
void updateSirene() {
|
||||||
|
if(sireneOn) {
|
||||||
|
unsigned long currentMillis = millis();
|
||||||
|
|
||||||
|
if (currentMillis - previousMillisAlarm >= interval) {
|
||||||
|
// Si le temps est écoulé, change de fréquence
|
||||||
|
previousMillisAlarm = currentMillis;
|
||||||
|
|
||||||
|
tone(D2, sirenTab[sirenIndex], 200);
|
||||||
|
|
||||||
|
sirenIndex = (sirenIndex + 1) % 2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
noTone(D2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void startSirene() {
|
||||||
|
sireneOn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopSirene() {
|
||||||
|
sireneOn = false;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user