Problem of interfacing analog accelerometer to "RESET" in Arduino UNO

I want to reset the analog accelerometer in order to go back to its normal mode operation or in its function...

I know that there is a reset connection in my microcontroller Arduino UNO... I put a jumper wire in the analog pin_2 and it is connected into RESET...

my problem is I did'nt get the correct way of coding... I want to reset it but it did'nt... I want to program the "reset" instead of using pushbutton reset in Arduino UNO...

Is it possible to make this program??? please give me a hint or idea on how to do it....

const int buttonPin = A1;    // analog input pin 1
const int groundpin = 18;    // analog input pin 4 -- ground
const int powerpin = 19;     // analog input pin 5 -- voltage
int xpin = A3;                   // x-axis of the accelerometer
int sensorValue = 0;           // variable to store the value coming from the sensor

void setup()
{

  Serial.begin(9600);
  
  pinMode(buttonPin, INPUT);     
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT); 
  digitalWrite(groundpin, LOW); 
  digitalWrite(powerpin, HIGH);
}

void loop()
{
  sensorValue = digitalRead(A1);
  
    if (sensorValue == HIGH){     
       sensorValue = analogRead(xpin);    
       Serial.print(analogRead(xpin));
       Serial.print("\t");
       Serial.println();
    }
  
    else{
       if (sensorValue == LOW){
          analogWrite(A5, LOW); 
       }
       
       else{
         if (sensorValue == HIGH){
            analogWrite(A2, LOW);
         }
         
         else{
            analogWrite(A2, HIGH);
         }
       }
    }
    
   
  delay(500);
}

I put a jumper wire in the analog pin_2 and it is connected into RESET...

You can do this but it will not work.

Simply connect the arduino pin to the reset pin of your device and toggle it. Do not mess with the arduino reset pin unless you know what you are doing which in your case you don't.

@ Mike

just like of example in Arduino "Button"???

Grumpy_Mike:

I put a jumper wire in the analog pin_2 and it is connected into RESET...

You can do this but it will not work.

Simply connect the arduino pin to the reset pin of your device and toggle it. Do not mess with the arduino reset pin unless you know what you are doing which in your case you don't.

can you tell me on how to toggle??? what you mean by toggle?? turn on and off???

what you mean by toggle?? turn on and off???

Yes to toggle means to change the logic level.
So to reset something whose reset line is connected to pin 2 simply do

digitalWrite(2,LOW);
digitalWrite(2,HIGH);

If the device needs longer in reset insert a delay between the two statements.