Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define Re 4
- #define LDR A0
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(Re,OUTPUT);
- pinMode(LDR,INPUT);
- }
- void(* resetFunc) (void) = 0; //declare reset function @ address 0
- void loop() {
- Serial.print("Secs: ");
- Serial.println(millis() / 1000);
- int ldr = analogRead(LDR);
- Serial.print("Strength: ");
- Serial.println(ldr);
- if (ldr <= 3){
- if ((millis()/1000) == 0){
- digitalWrite (Re,LOW);
- }
- if ((millis()/1000) == 3600){
- digitalWrite (Re,HIGH);
- }
- if ((millis()/1000) == 14400){
- Serial.println("resetting");
- resetFunc(); //call reset
- delay(100);
- }
- }
- if (ldr >4){
- digitalWrite(Re,HIGH);
- delay(5000);
- resetFunc(); //call reset
- delay(5000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement