Arduino NANO freezing problem

I’m fairly new to electronics and Arduino world (Just starting my Micro controllers).

I have a nano (clone) with which I’m making a watt-meter to measure AC voltages (stepping down via transformer and then voltage divider) and AC current via hall effect sensor (ACS-712) and then finding the power by simply multiplying them (working with resistive loads for the start) and putting them on display on a standard 16x2 LCD.

My problem is that it works fine, the ADCs’ work fine if I keep it running for longer periods, but if I switch my device (AC bulb) ON and OFF in short intervals, the ADC freezes, keeps displaying zero on LCD even though the voltages appear on the ADC pin.
Sometimes, ADCs won’t even work when I start the controller and then switches ON AC loads.
Could find anything on forums, I couldn’t possibly be the only one.
Sorry for my bad English.

#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

//#include <avr/wdt.h>

const unsigned long sampleTime = 100000UL; // sample over 100ms, it is an exact number of cycles for both 50Hz and 60Hz mains
const unsigned long numSamples = 250UL; // choose the number of samples to divide sampleTime exactly, but low enough for the ADC to keep up
const unsigned long sampleInterval = sampleTime / numSamples; // the sampling interval, must be longer than then ADC conversion time
const int adc_zero = 518; // relative digital zero of the arudino input from ACS712 (could make this a variable and auto-adjust it)
float volt, voltage = 0, I = 0, power = 0, prevpower = 0, prevvoltage = 0;
int n = 0;

void setup()
{
// wdt_enable (WDTO_1S); // reset after one second, if no “pat the dog” received
lcd.begin(16, 2);
lcd.setCursor(1, 0);
lcd.clear();
delay(500);
lcd.print(“Starting Power”);
lcd.setCursor(3, 1);
lcd.print(“Measurement”);
delay(750);
lcd.clear();
//Serial.begin(9600);
}

void loop()
{
for (int i = 0; i < 250; i++)
{
volt = analogRead(A3);
volt = (volt * 5) / 1024;
voltage += volt;
}

voltage = voltage / 250;
voltage = (voltage * 56.611);
//Serial.print(voltage);
//Serial.print(" ");

I = currentRead(A2);
I = I - 0.15;

if (I < 0.2) {
I = 0;
voltage = 0;
}

power = voltage * I;
if (power < 10)
power = 0;

if (n == 0)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(voltage);
lcd.print(" ");

lcd.setCursor(7, 0);
lcd.print(I);
lcd.print(" “);
//Serial.print(I);
//Serial.print(” ");

lcd.setCursor(12, 0);
lcd.print(power);
n++;
}

if (n==1 && (power <= (prevpower - 10) || power >= (prevpower + 10) || voltage <= (prevvoltage - 10) || voltage >= (prevvoltage + 10)))
{
prevpower = power;
prevvoltage = voltage;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(voltage);
lcd.print(" ");

lcd.setCursor(7, 0);
lcd.print(I);
lcd.print(" “);
//Serial.print(I);
//Serial.print(” ");

lcd.setCursor(12, 0);
lcd.print(power);
//Serial.println(power);
}
// delay(100);
//wdt_reset();
}
float currentRead(int currentPin)
{
unsigned long currentAcc = 0;
unsigned int count = 0;
unsigned long prevMicros = micros() - sampleInterval ;
while (count < numSamples)
{
if (micros() - prevMicros >= sampleInterval)
{
int adc_raw = analogRead(currentPin) - adc_zero;
currentAcc += (unsigned long)(adc_raw * adc_raw);
++count;
prevMicros += sampleInterval;
}
}

float rms = sqrt((float)currentAcc / (float)numSamples) * (50 / 1024.0); //for 20A sensor, 5V/X = 100 ; For 30A, Use 5V/X = 75.7565

return rms;
}