I'm making some kind of voltage alarm. I have three voltage sensors connected to the analog inputs and one sensor at the digital input. How to write a program that detects the first two inputs A0 and A1 too high or too low voltage and immediately writes it to the digital output for 5 seconds (HIGH) then back to (LOW) and waits until the value returns to the set. However, the sensor at input A2 only detects too low a voltage value. On the digital input 2 there is a switch that detects if the lid of the box where the sensor is located is closed.
you should use constants for IO-pins-numbers instead of hardcoded direct numbers.
This will make your code easier to understand and easier to maintain.
you do not have even a comment what IO-pin 2,9,10,11,12 are for.
So I'm using names that could make sense but will not describe what they mean in your project,
It is just to show the principle.
and then your sentence goes on
"but I intended to make a security system"
in this case the word "but" indicates instead of needing such a system you planned in the past) to make a security system (which seems something different) than the systemA
As this planning was in the past what are you doing now in the present?
I assume you mean something different but thats what your english words are saying.
If english is not your native language use google-translate.
I guarantee that if you write what you want to say in your motherlanguage and let do google-translate the translation it will be much better understandable.
Addition: you have a very unconventional way of drawing electronic schematics.
It was an interesting exercise to re-draw a part of your schematic to the usual way to understand how the rersistors are connected.
I want to use this device to control a mesh fence for animals. After the fence above and below I will install a wire in between I will add a 10kohm resistor which will serve as a voltage divider along with a 15kohm resistor on the circuit. The actual intermediate voltage then becomes halfway from the input and so I sense that an error has occurred if someone inserts a bridge over the complete circuit.
I sense this at inputs A0 and A1.
At input A2, I measure the voltage of the battery to power the entire system so that it does not discharge too much.
On the digital input 2 I have the system box door connected so that in the event of the box opening an alarm is triggered.
Output IO 12,11,10 and 9 I have a connected wireless transmitter.