Hello everyone,
This will be my first time posting within the forums so I apologize if I muck it up! Please bear with me on this one, it may be much easier than I'm making it out to be. I certainly do not offer this as an excuse but to explain any of my failings, all of my knowledge with arduino, the code, and the electrics is self taught, so I may make a mountain out of a mole hill
That being said, on to the meat of it with a brief summary of what I am attempting to create:
GREATLY, thank to many authors and skilled coders from GitHub, I have been working on an arduino controlled access system at my home. My better half and I live in a very large apartment above the business my family and I own. The tedium arrived with our stairwell. We have two locking doors which keep unwanted guests out. In a stroke of laziness I found myself looking at solutions for a tag in/tag out system for the doors so we would not constantly have to use keys.
I have, again thanks to much of the information I've found here/GitHub, managed to code up most of the system and performed a few initial tests and so far... success! So I am now working toward a more polished code as well as trying to clean up said code so that I can post it up for others to use in the event that it can in some way be helpful. While unlikely in my mind, I'd like it to be clean and easy to read/breakdown if needed. I digress...
I am currently trying to write a sequence which the micro controller will use to startup and check the components (check for faults and failures) and my question comes in here.
Here's the basic layout:
- 1 - Arduino Uno R3
- 1 - SeeedStudio 4 Bay Relay Shield
- 1 - SainSmart 4 Bay Relay Board
- 1 - Sunfounder RFID Reader
- 1 - DIY "Push to Exit" Control Terminal
- 2 - 12VDC Power Source
The "Push to Exit" Control Terminal Houses:
- 3 - Basic Small 12v LED
- 2 - Basic Large 12v LED
- 1 - Push Button 2 Position
I'll include photos if anyone is interested.
Here's what I'd like some guidance with (or perhaps a good slap to let me know it's not possible!)
Goal:
I'd like the startup sequence to allow the power sources a moment to power up (approx. 10 seconds) and then run a system check on each component. Cycling each unit (total of 9 checked) which has power regularly and checking for failures. What I'm not certain of is if A) What I have now is accomplishing that in small way and B) If there is a working and/or better way.
I've attached my 'WorkBench' copy of the code for the full gambit, but the rub is here:
Serial.println("System warm up"); //Opening block to let the system startup.
for(int i = 0; i < startupTime; i++){
Serial.print(".");
delay(2000); }
digitalWrite(agRelayPin, HIGH); // COMMENT 1: This sets all of the components to off (or relays on)
digitalWrite(ayRelayPin, HIGH); // as the components are currently wired as NO.
digitalWrite(arRelayPin, HIGH);
digitalWrite(arRelayPin, HIGH);
digitalWrite(ldMagRelay, HIGH);
digitalWrite(udMagRelay, HIGH);
digitalWrite(ldStkRelay, HIGH);
digitalWrite(udStkRelay, HIGH);
delay(1500);
if((agRelayPin == HIGH) && (ayRelayPin == HIGH) && (arRelayPin == HIGH) && (abRelayPin == HIGH) && // COMMENT 2: This is a basic dummy check, probing the units just in case one doesn't respond?
(ldMagRelay == HIGH) && (udMagRelay == HIGH) && (ldStkRelay == HIGH) && (udStkRelay == HIGH)) {
delay(500);
Serial.println("Running system diagnostics.");
delay(500);
}
Serial.println("Access LED (G)..."); // COMMENT 3: Here the checks would begin, each one changes the state twice and then runs the purposed check.
digitalWrite(agRelayPin, LOW);
delay(100);
digitalWrite(agRelayPin, HIGH);
delay(100);
digitalWrite(agRelayPin, LOW);
agStat = digitalRead(agRelayPin);
if(agStat == LOW) {
Serial.println("Access LED (G) OK.");
delay(2000);}
else {
Serial.println("Access LED (G) FAULT.");
int faultcode = 1; // COMMENT 4: In the event that, for instance, the Green LED fails, faultcode is changed to 1 and moves down to the label: 'faulted'
faulted();
}
MS_WorkBench2.ino (7.53 KB)