Hello community,
I am working on a very simple project: I need a particular computer (to which I connect remotely from my home) powered up at all times. So I have set it up to restart automatically after a power failure.
The problem is that I realized that over this summer there were a lot of blackouts in that area (I know this because even though the computer is running the apps I left running are not).
So my plan is to use a battery backup UPS unit. This unit would detect a blackout and shut down this computer properly.
Here where Arduino enters. When the power is restored, Arduino will power up, check the status of the computer and power it up.
Just as a precocious measure, I am making Arduino to check the power status of this computer every 5 minutes and power it up if 3 consecutive times it was detected powered off.
(Note: I am using for test purposes delay(3000) )
int PCDETECT = 0; // PC ON / OFF detector
int COUNT = 0; // Counter
void setup()
{
pinMode(A0, INPUT); // Connected to PC's power LED +
// (here I'm connecting it with a jumper to 3.3V pin on Arduino)
pinMode(13, OUTPUT); // Connected to PC's power button -
}
void loop()
{
PCDETECT = analogRead(A0);
// delay(3000);
if (PCDETECT < 80 and COUNT > 3)
{
digitalWrite(13, 1); // Send +5VDC to PC's power pin
delay(500); // for 0.5 seconds
digitalWrite(13, 0);
COUNT = 0;
delay(3000); // This is the wait interval
}
else
{
// delay(100);
COUNT ++;
// delay(3000);
}
// delay(1000);
}
Please note the " // delay(3000)'s and delay(1000)'s " here and there.
This sketch without the // delay()'s works just fine, but if I use the "commented" delay()'s anywhere in the sketch it stops working: The pin 13 never sends any pulse/HIGH.
Any help will be appreciated!
Thank you.