hi
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
shutdown
here's a basic flowchart of the process needed to code
I know goto is frowned upon mostly
start:
if PSU input LOW turn led on standby blinking amber
if input HIGH goto voiceON:
else goto start: to read input
voiceON:
switch voice on 5 sec
switch off
turn on green led if input still high
if input low GOTO shutdown:
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() {
start:
int analogValue = analogRead(analogPin); // read Analog pin A0
{digitalWrite(voiceON, LOW);}
if (analogValue < threshold) {goto AMBER;}
if (analogValue > threshold) {goto voiceON;}
AMBER:
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;}
voiceON:
if (analogValue > threshold){digitalWrite(voiceON, HIGH);}
if (analogValue < threshold){digitalWrite(voiceON, LOW);}
if (analogValue > threshold) {digitalWrite(PSUON, HIGH);}
else {goto AMBER;}
}