ok so for the past 2 hours iv been playing around with this code http://pastebin.com/m1216787f and im trying to get it set onto mode 3, where it works using a light depended risistor.
and i dont know how to the crappity smack to get it into the mode ?
OR
if some one could. could some one write me a small code that will turn the servo one way when light hits the light dependent risistor, and then it turns the other way when there is no light on it ?
i would realy apreshiate it, as im building an automatic door for my pet chickens.
did you intend it to toggle when analogRead(LIGHTPIN) is less than LIGHTTHRESHOLD ?
I would have thought that you would turn it on or off depending on the light level.
anyway, a tip is to write a simple test sketch that just handles the photocell code and use Serial.print statments if you need to debug this.
if(analogRead(LIGHTPIN) < LIGHTTHRESHOLD){ //if light is brighter than the threshold value
turnOn();
}
else{
turnOff()
}
delay(1000); //wait a second to avoid double toggling
lastRun = millis(); //set lastRun to current time
I am not sure what lastRun does but this should get you closer.
I strongly suggest that if you need more help with this part of the code that you write a simple sketch that just reads the light level and calls a turnOn or turnOff function that prints a message to the serial monitor. When you have that logic working as you want you can add it back into that servo code.