I have a signal that is changing from 0 to 5 volts a few times a second, said circuit also becomes open at times as well.
I am trying to write the program so i have an output when the signal drops below a certain voltage threshold as well as drops for a said amount of time (to signal when circuit is open). below is what i have so far, not working, any help is appreciated.
const int analogPin = A0;
const int ledPin = 13;
const int voltage threshold = 1000;
unsigned long startTime;
unsigned long elapsedTime ;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int analogValue = analogRead(analogPin);
if (analogValue < voltagethreshold); {
digitalWrite(ledPin, HIGH);
}
Serial.println(analogValue);
}
[code]