Hello Everyone,
I am kind of new to Arduino coding in this detailed, but have done a gaming platform involving serial communication, but I am far from the experts here in this forum and appreciate any help or guidance as to why some problems are occurring. I have a couple of questions concerning the coding of multiple identical sensors (New circle version HB100X adjustable) and the way to get them to work independently no matter which one is triggering the 4 Bank relays.
Coding maybe be messy or not correct but like I mentioned any help or guidance will be greatly appreciated, just getting tired of people stealing my hard earned stuff from my property.
Q1. example problem- if relay1 has been triggered... R2,R3,R4 will not trigger until R1 has triggered off, but if R2,R3,R4 has been triggered R1 will trigger fine?
Q2. Can I create 4 separate folders for each of the Doppler Radar units or is there a better way of isolating them with coding?
Q3. Does anyone know if I will have to add Frequency code with the New 3pin version of the HB100X if I am not worried about speed or frequency, I'm only worried about the detection with in distance of my property?
Hardware as follows,
Gen Arduino Mega 2560
4 New circle version HB100X adjustable 3pin V+, G-, Out (from ebay)https://sparkfruit.ph/product/mh-et-live-hb100-x-10-525ghz-microwave-sensor/
5v 4 channel relay
2 Sound modules
4 HD camera - Will work independently and may not be directly connected to the mega2560 Not sure yet
1 alarm buzzer (for all relays) 3-24v
4 10mm LED pre-wired
/*Doppler Radar Test Arduino Mega 2560*/
// Analog Pins used
int dopplerA4 = A4;
int dopplerA6 = A6;
int dopplerA8 = A8;
int dopplerA10 = A10;
int soundsensA12 = A12;
// Digital Pins used
int relay2 = 2;
int relay3 = 3;
int relay4 = 4;
int relay5 = 5;
int alarm6 = 6;
// Read the sensors
int analogValue = 0;
int sensorRead = 0;
int sensorValue = 0;
int sensValue = 0;
int sensRead =0;
// threshold value setting to decide when motion is detected.
int threshold = 400;
void setup() {
// Setup serial monitor
Serial.begin(9600);
// Initialize input pins
pinMode (dopplerA4, INPUT);
pinMode (dopplerA6, INPUT);
pinMode (dopplerA8, INPUT);
pinMode (dopplerA10, INPUT);
pinMode (soundsensA12, INPUT);
// Initialize output/ high or low
pinMode (relay2,OUTPUT);
digitalWrite(relay2,HIGH);
pinMode (relay3,OUTPUT);
digitalWrite(relay3,HIGH);
pinMode (relay4,OUTPUT);
digitalWrite(relay4,HIGH);
pinMode (relay5,OUTPUT);
digitalWrite(relay5,HIGH);
pinMode (alarm6,OUTPUT);
digitalWrite(alarm6,HIGH);
}
// Main loop
void loop() {
analogValue = analogRead (dopplerA4);
sensorRead = analogRead (dopplerA6);
sensorValue = analogRead (dopplerA8);
sensValue = analogRead (dopplerA10);
sensRead = analogRead (soundsensA12);
// if the sensor reading is greater than the threshold.
if (analogValue >= threshold) {
// toggle the status of the relayPin (LOW is On) (HIGH is OFF).
digitalWrite(alarm6, LOW);
digitalWrite(relay2, LOW);
Serial.println("Alarm Triggered!"); // send the string "Alarm On!" back to the computer.
Serial.println("Relay2 On!");
}else{
digitalWrite(alarm6, HIGH);
digitalWrite(relay2, HIGH);
Serial.println("Alarm OFF!"); // send the string "Alarm On!" back to the computer.
Serial.println("Relay2 OFF!");
delay (500);
if (sensorRead >= threshold) {
digitalWrite(alarm6, LOW);
digitalWrite(relay3, LOW);
Serial.println("Alarm Triggered!"); // send the string "Alarm On!" back to the computer.
Serial.println("Relay3 On!");
}else{
digitalWrite(alarm6, HIGH);
digitalWrite(relay3, HIGH);
Serial.println("Alarm OFF!"); // send the string "Alarm OFF!" back to the computer.
Serial.println("Relay3 OFF!");
delay (500);
if (sensorValue >= threshold) {
// toggle the status of the relayPin (LOW is On) (HIGH is OFF).
digitalWrite(alarm6, LOW);
digitalWrite(relay4, LOW);
Serial.println("Alarm Triggered!"); // send the string "Alarm On!" back to the computer.
Serial.println("Relay4 On!");
}else{
digitalWrite(alarm6, HIGH);
digitalWrite(relay4, HIGH);
Serial.println("Alarm OFF!"); // send the string "Alarm On!" back to the computer.
Serial.println("Relay4 OFF!");
delay (500);
}
}
}
}
Doppler_Radar_Test_Mega_10.12.2019.ino (3.06 KB)