Problem using code to activate reset pin on Mega

/*
Expecting digitalWrite(armButtonRstPin, LOW); to send 0v to reset pin on uno. Not sure why I'm getting 5v reading on digitalRead(armButtonRstPin)

Thank YouUse code tags to format code for the forum
*/

int armLedPin = 6;
int armButton = 22;
int armButtonRstPin = 24;

void setup() {
pinMode(armButton, INPUT_PULLUP);
pinMode(armLedPin, OUTPUT);
pinMode(armButtonRstPin, INPUT_PULLUP);
}
/* armButton is set floating/pulled high.
The default state of the Arduino Uno reset pin is high-impedance (floating), but it is actively held high by an internal pull-up resistor to a default stable state. When the reset button is pressed, or when the pin is pulled low by an external circuit, it triggers a reset by sending a LOW signal to the microcontroller.
*/
void loop() {
Serial.begin(9600);
if (digitalRead(armButton) == LOW){
digitalWrite(armButtonRstPin, LOW);
digitalWrite(armLedPin, HIGH);
Serial.println(digitalRead(armButton)); // Serial.print = 0
Serial.println(digitalRead(armLedPin)); // Serial.print = 1
Serial.println(digitalRead(armButtonRstPin)); // Serial.print = 1
delay(1000);
}

}

The Uno does not have a pin 22 or 24.
What are you trying to do?

1 Like

In addition to what @jim-p rightly clarifies to you, remember that the pin armButtonRstPin is defined as INPUT_PULLUP (and that's fine for what you want to do), but you must change it to OUTPUT to do the reset.

if (digitalRead(armButton) == LOW){
  digitalWrite(armButtonRstPin, LOW);
  pinMode(armButtonRstPin,OUTPUT);

Keep in mind that whatever you do after this will not be executed because the micro restarts.

Sorry, I'm using a Mega.
I'm wanting to reset the Mega board by pushing the armButton. When pushing the armButton, expecting 0 volts to be sent to the Reset pin, resetting the Mega board. This is exert code (for testing) a single axis plasma cutter I'm building. My thought was to push the armButton which would in turn send a ground to the reset pin on the Mega, resetting it.
Thanks

Then just connect the button to the RESET pin, no code necessary

2 Likes