Need assistance with a voltage read/led blink circuit.

I posted this the other day and thought it was fixed but i am back to having issues so I am making a new thread to include more information. The circuit and Arduino code are below. If anyone can see why this is not working consistently can you let me know? It uses 2 resistors one 3.3k and one 2k which lowers the 12.6 volt lipo down to below 5 volts so i can read it using the analogread on pin A0. Then when it hits the voltage lower limit it should run the code and tell it open and close the mosfet letting me know the voltage has reached the threshold. It works some times some times not. I have bought all brand new components, 4 different arduinos (Official arduino uno, knock off arduino uno, knock off arduino nano, and Adafruit Trinket. Maybe i am wiring it up wrong?

const int led=9;

const int batV=A0;

void setup () {

pinMode(led, OUTPUT);

}

void loop () {

int volt2 = analogRead(batV);

if (volt2 <= 906)

{

digitalWrite(led, HIGH);

delay(1000);

digitalWrite(led, LOW);

delay(1000);

}

else

{

digitalWrite(led, HIGH);

}

}

Put a 1k resistor in series with your LED. Another one to the MOSFET gate from the Arduino wouldn’t hurt either.

Putting a resistor there would lower the voltage to my leds wouldnt it? They run on 12 volts so 12.6 is no issue safe up to roughly 13.5.

Sent from my SAMSUNG-SM-N910A using Tapatalk