Hello,
I use the arduino Nano.
I'm trying to create a delay signal (~1.2sec) after turning power ON.
Pin "D2" reading power ON, with a resistor 20K to GND and 1K to +5V
Pin "D13": output for delay signal
But I get an oscillation on signal output ?!
Could anyone please explain this issue ?
Here is my code:
// Set pin numbers:
const int powerOn = 'D2'; // at pin #2, adding a resistor 1K pull up and a resistor 20K to GND !!! ***
const int BLM_RESET = 'D13';
// variables will change:
int poweronState = 0; // variable to read the status of power
void setup() {
// initialize the powerOn pin as an input:
pinMode(powerOn, INPUT);
// initialize delai_1.2 s as an output:
pinMode(BLM_RESET, OUTPUT);
// read the state of the poweronState value:
poweronState = digitalRead(powerOn);
}
void loop() {
// check if the power is ON. If it is, the pin #2 is HIGH:
if (poweronState == HIGH) { // power is ON
delay(1200); // waiting for 1200 ms (1.2s) before BLM_RESET is actived HIGH
digitalWrite(BLM_RESET, HIGH);
}
else {
// if power is OFF, turn BLM_RESET off:
digitalWrite(BLM_RESET, LOW);
// delay(20);
}
}

