Ok i am trying to create a circuit which will turn on a huge string of 12 volt leds using an arduino. I have the code i wrote and a voltage divider circuit and a mosfet circuit. The circuit works. It does not however work correctly. I turned my arduino temporarily into a voltage meter and read 1023 on pin 1 analog. This is right where id like to be roughly as my battery is at 12.4 instead of 12.6 which should bring it up to 1024. However my circuit blinks the LEDS at any voltage detected until i tell it to detect anything 100 or less on pin 1. I will include my code and see if anyone can assist me. I am brand new and this is a learning experience and i did do research before i asked but nothing was found that seemed relevant.
const int led=9;
const int batV=analogRead(A1);
void setup () {
pinMode(led, OUTPUT);
}
void loop () {
int volt2 = analogRead(batV);
if (volt2 <= 800)
{
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
else
{
digitalWrite(led, HIGH);
}
}