pc power supply monitor

this is for a computer project regarding the power supply

for a computer power supply to have a voice play when the

PSU is switched on, and also monitors the input

while it is off (on standby) there is a blinking amber led,

using the 5vSB psu rail

green led goes on when psu is on

when the PC shuts down a voice file plays to say it has


here's a basic flowchart of the process needed to code

I know goto is frowned upon mostly


if PSU input LOW turn led on standby blinking amber
if input HIGH goto voiceON:
else goto start: to read input

switch voice on 5 sec
switch off
turn on green led if input still high

if input low GOTO shutdown:

say system shutdown
goto start:

also after the PC has powered up it has to know when it is shutting down too and that's where the difficulty started.

4 leds are used to monitor the conditions so i can see whats happening.

const int analogPin = A0;    // pin that the sensor is attached to
const int PSUON = 3;       // pin that the green LED is attached to
const int PSUSB = 5;       // pin that the amber LED2 is attached to
const int voiceON = 2;      // FET1
const int PSUShutDown = 4;    //FET2
const int threshold = 850;   // an arbitrary threshold level

void setup() {
  pinMode(PSUON, OUTPUT);
  pinMode(PSUSB, OUTPUT);
  pinMode(voiceON, OUTPUT);
  pinMode(PSUShutDown, OUTPUT);

void loop() {
  int analogValue = analogRead(analogPin);  // read  Analog pin A0
  {digitalWrite(voiceON, LOW);}
  if (analogValue < threshold) {goto AMBER;}
  if (analogValue > threshold) {goto voiceON;}

if (analogValue < threshold) {digitalWrite(PSUON, LOW);}
if (analogValue < threshold){digitalWrite(voiceON, LOW);}
{digitalWrite(PSUSB, HIGH);}
delay (555);
  {digitalWrite(PSUSB, LOW);}
delay (555);
if (analogValue < threshold){goto start;}
if (analogValue > threshold) {goto voiceON;}

 if (analogValue > threshold){digitalWrite(voiceON, HIGH);}
 if (analogValue < threshold){digitalWrite(voiceON, LOW);}
 if (analogValue > threshold) {digitalWrite(PSUON, HIGH);}
 else {goto AMBER;}


What device is controlled by the pin voiceON ?
What are you actually monitoring during standby and are you monitoring anything at the mains voltage level ?

modified mp3 player with SD card recording.

monitoring the 5v on the PSU.

no mains voltages here.