Internal Resistance Measurement

Hi.. I'm trying to measure the internal resistance of my lithium-ion battery, my problem is how to stop the measurement when the Arduino reads voltage at no load, and when I turned the switch connected with 10ohm,5W resistor which I will use as my load to get the Vload, so that

Rint = R( Vnoload - Vload ) / Vload

so far this is my code. Thank you for your help guys. <3

#include "Wire.h"
#include "LCD.h"
#include "LiquidCrystal_I2C.h"


#define I2C_ADDR 0x3F  // Add your address here.
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7



LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
 lcd.begin (20,4); //  our LCD is a 20x4, change for your LCD if needed

// LCD Backlight ON
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);

lcd.home (); // go home on LCD
lcd.print("  GENERATOR RATING"); 
}

void loop()
{
  printVolts();
}
 
 void printVolts()
{


int sensorValue = analogRead(A0);
float voltage1 = sensorValue * (5.00 / 1023);


 lcd.setCursor (0,1); // go to start of 2nd line
 lcd.print(voltage1);
 lcd.print(" V");

 

}

If you want to do something once in loop() then set a boolean variable to true when you first do it and make doing it dependant on the variable being false

if (theReadingHasBeenTaken == false)

  {
     the readingHasBeenTaken = true;
     //take the reading
  }

I tried this code but I get all readings at 1.0V, can you tell me what's wrong with the code? thank you sir..

int sensorValue = analogRead(A0);
float voltage1 = sensorValue * (5.00 / 1023);

if (voltage1 == false)

  {
     voltage1 = true;
     //take the reading
  }

Serial.println(voltage1);
 
 lcd.setCursor (0,1); // go to start of 2nd line
 lcd.print(voltage1);
 lcd.print(" V");
 delay(3000);
float voltage1 = sensorValue * (5.00 / 1023);

if (voltage1 == false)

  {
     voltage1 = true;

a float that is also a boolean?

Hi this is the schematic I'm using (attached) but the I'm getting the same result, what I want to get is the recorded value of voltage at no load, after I press the switch the reading at A0 will stop and then reading at A1 is the Vload rating of the battery. After that, I can proceed with internal resistance calculations... thank you

AWOL:

float voltage1 = sensorValue * (5.00 / 1023);

if (voltage1 == false)

{
    voltage1 = true;



a float that is also a boolean?

LOL, I'm sorry bout that, I'm really trying anything to make this thing work..