// blinkprtpw
byte ledPin = 2;
byte potPin = 14;
bool state = 0;
unsigned long timerL, timeoutL = 100, timeoutLold, timerH, timeoutH, timeoutHold;
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}
void loop() {
timeoutH = map(analogRead(A0), 0, 1023, 50, 250); // PRF 50ms to 250ms
timeoutL = map(analogRead(A1), 0, 1023, 50, 250); // PW 50ms to 250ms
if ((!state) && (millis() - timerL > timeoutH)) { // compare LOW timer for HIGH timeout
timerH = millis(); // reset HIGH timer
digitalWrite(ledPin, HIGH);
state = 1; // indicate pulse HIGH state
}
if ((state) && (millis() - timerH > timeoutL)) { // compare HIGH timer for LOW timeout
timerL = millis(); // reset LOW timer
digitalWrite(ledPin, LOW);
state = 0; // indicate pulse LOW state
}
showPRTPW();
}
void showPRTPW() {
if ((timeoutHold != timeoutH) || (timeoutLold != timeoutL)) {
timeoutHold = timeoutH;
timeoutLold = timeoutL;
Serial.print(timeoutH);
Serial.print(" ");
Serial.print(timeoutL);
Serial.println();
}
}
PRT
PW