sorry for not explaining in detail.....
here i again made some modifications to my code.....and its important to note that i am using three pushbuttons for seprate pin(function)... i also made some modifications to my function than i wanted earlier
reset button ----pin 2--- start the light on 6pm and off at 6am(this pin is working great)
on button ----pin 3---start the light when i preses the button and off at 12. on the next day. i should not have to press button again. it should be on automatically at the time when i pressed the switch earlier and again should be off at 12 again...this cycle should go on each day automatically until i press the other switchand jump to another function
off button----pin 4---off the light when i press the button and should be on at the time when i pressed earlier pushbutton(pin 3 which is for on). again without pressing any button this cycle should go on contineously every day until i press other one.....
and yes exactly....
i want to store that button press time in the eprom... but i dont know how.....?
i am unable to add third function to my program thts why i switch on the light at 6pm again(u can see this in prgram)
how do i make it on at the button press time of pin 3
code[]
#include <Arduino.h>
#include <Wire.h>
#include <RTClib.h>
const int light = 13;
int y1;
int y2;
int z1;
int z2;
const int buttonPin[] = {2,3,4};
int buttonState = 0;
RTC_DS1307 rtc;
void setup()
{
Serial.begin(9600);
Wire.begin();
rtc.begin();
pinMode(light, OUTPUT);
for (int x=0; x<3; x++)
{
pinMode(buttonPin
}
}
void loop(){
DateTime now = rtc.now();
for(int x=0; x<3; x++)
{
buttonState = digitalRead(buttonPin
{ if (buttonState == 0 && buttonPin
{ if (now.hour() == 4 && now.minute() == 22)
{
digitalWrite(light, HIGH);
}
}
else (buttonState == 1 && buttonPin
{ if (now.hour() == 10 && now.minute() == 22)
{
digitalWrite(light, LOW);
}
if (now.hour() == 4 && now.minute() == 22 )
{
digitalWrite(light, HIGH);
}
}}
{ if (buttonState == 0 && buttonPin
{int z1 = now.hour();
int z2 = now.minute();
if(now.hour() == z1 && now.minute()== z2)
{
digitalWrite(light, HIGH);
}
}
else(buttonState == 1 && buttonPin
{ if (now.hour() == 10 && now.minute()== 22 )
{
digitalWrite(light, LOW);
}
if(now.hour() == z1 && now.minute()== z2)
{
digitalWrite(light, HIGH);
}
} }
{if (buttonState == 0 && buttonPin
{ int y1 = now.hour();
int y2 = now.minute();
if (now.hour() == y1 && now.minute() == y2)
{
digitalWrite(light, LOW);
}}
else (buttonState == 1 && buttonPin
{ if (now.hour() == 4 && now.minute()== 22)
{
digitalWrite(light, HIGH);
}
if (now.hour() == y1 && now.minute() == y2)
{
digitalWrite(light, LOW);
}
}
}
}
}
code[]