hi there thanks for that information i will bare that in mind for other projects. the project is working how i wanted it to now but by all means say if you see something you dont like
// Example 02: Lighting Timer 26/10/2011
#define A_light 13 // Light A on pin 13
#define B_light 12 // Light B on pin 12
#define C_light 11 // Light C on pin 11
#define D_light 10 // Light D on pin 10
#define time_button 7 // Button on pin 7
#define A_light_button 1// Light A button
#define B_light_button 2// Light B button
#define C_light_button 3// Light C button
#define D_light_button 4// Light D button
int timebutton = 0;
int buttonA = 0;
int buttonB = 0; // val will be used to store the
int buttonC = 0; // state of the input pin
int buttonD = 0;
void setup() {
pinMode(A_light, OUTPUT);
pinMode(B_light, OUTPUT); //Setting the digital
pinMode(C_light, OUTPUT); // pin's as output
pinMode(D_light, OUTPUT);
pinMode(time_button, INPUT);
pinMode(A_light_button, INPUT);
pinMode(B_light_button, INPUT);
pinMode(C_light_button, INPUT); // Setting as an input
pinMode(D_light_button, INPUT);
}
void loop ()
{
timebutton = digitalRead(time_button); //read input value and store it
buttonA = digitalRead(A_light_button); //read input value and store it
buttonB = digitalRead(B_light_button); //read input value and store it
buttonC = digitalRead(C_light_button); //read input value and store it
buttonD = digitalRead(D_light_button); //read input value and store it
if (buttonA == HIGH) { // if button A is on do the following
digitalWrite(A_light, HIGH); //turn A light on
delay(900000UL); // wait for 15 mins
if (timebutton == HIGH) {
delay(900000UL); // delay for an additional 15 mins if HIGH
}
digitalWrite(A_light, LOW); // turn A light off
delay(1000); //turn all off for 1 second
}
if (buttonB == HIGH) { // if button B is on do the following
digitalWrite(B_light, HIGH); //turn B light on
delay(900000UL); //waint for 15mins
if (timebutton == HIGH) {
delay(900000UL); // delay for an additional 15 mins if HIGH
}
digitalWrite(B_light, LOW); //turn B ligt off
delay(1000); //turn all off for 1 second
}
if (buttonC == HIGH) { // if button C is on do the following
digitalWrite(C_light, HIGH); // turn C light on
delay(900000UL); // waint for 15 mins
if (timebutton == HIGH) {
delay(900000UL); // delay for an additional 15 mins if HIGH
}
digitalWrite(C_light, LOW); // turn C light off
delay(1000); //turn all off for 1 second
}
if (buttonD == HIGH) { // if button D is on do the following
digitalWrite(D_light, HIGH); // turn D light on
delay(900000UL); // waint for 15 mins
if (timebutton == HIGH) {
delay(900000UL); // delay for an additional 15 mins if HIGH
}
digitalWrite(D_light, LOW); // turn D light off
delay(1000); //turn all off for 1 second
}
}
and this how i was wiring the switches