Hello,
I'm 20 and just bought my first house, i'm completely rebuilding it
and would like to install domotics. I have a diploma in electronics and chose for Arduino because I belive in the Open Source idea.
I'm using push buttons in my house who power 24VDC relays, those relays give signal to a Arduino Mega 2560.
The Arduino exits are connected to 5V relays who power 230V AC lights or 230V AC dimmer modules
So I basicly only need the button and the switch programs, I can find both in the libarys
The problem is i never learned how to program using .html
If I use the button and switch program and rename everything I can get my Arduino to work
But if I use 2 working programs with diffrent names they don't work, do I need to end a program somehow before I type the next program?
Also does anyone have a idea how I would realise the following:
Pushbutton1 sets relay1 as switch
Pushbutton2 sets relay1 as switch but when relay1 is powered Push button 2 has no effect.
and
Pushbutton3 sets relay2 as switch
Pushbutton4 sets relay2 as switch but only for 2 minutes then relay2 gets turned off. (If relay2 was already turned on it stays on for 2 minutes)
I have been trying to make this work since november but no luck so far. I would really like Open Source domotics, if someone who understands Arduino programming would be able to get me on the right track I'd be for ever greatful. If someone would like a small tip for his help we could work something out too.
It sounds like you need to implement a single sketch which checks several inputs and then changes several outputs depending upon their status. With the Arduino running at 16 MHZ, it has plenty of time to check and update many pins thousands of times a second.
The cunning and elegant way to do this would probably be to use a couple of arrays to hold your pin definitions but you have plenty of space so the brute-force way will work perfectly well.
I'm not sure whether you want the output to simply reflect the state of the input (ie to be on when the input relay is closed) or whether you want it to toggle (ie to change state each time there is a short pulse from the relay) For the former you want a sketch that goes along these lines (obviously this is only an outline and not a real sketch):
int inputA = 3;
int inputB = 4;
....
int inputX = X;
int outputA = 9;
int outputB = 10;
...
int outputX = Y;
void setup(){
pinMode(inputA, INPUT);
....
pinMode(inputX, INPUT);
pinMode(outputA, OUTPUT);
...
pinMode(outputX, OUTPUT);
}
void loop(){
if(digitalRead(inputA))digitalWrite(outputA, HIGH);
else digitalWrite(outputA, LOW);
....
if(digitalRead(inputX))digitalWrite(outputX, HIGH);
else digitalWrite(outputX, LOW);
delay(100) // Delay to avoid burning out your relays by switching a thousand times a second! Change this as you wish.
}
For a toggle sketch, you would declare a boolean (true/false) variable for each switch and change the state of that variable (stateA=!stateA;) each time the HIGH and then LOW was detected.
shivathedestroyer:
I'm using push buttons in my house who power 24VDC relays, those relays give signal to a Arduino Mega 2560.
I'm confused by your description of switches and relays - and your circuit diagrams haven't helped much because you seem to have switches labeled as relays.
If the purpose of the push button (switch) is to provide a signal to the Arduino then I would have thought you could just connect the switch to the Arduino - the relay doesn't seem to be adding anything.
Dr_Ugi:
It sounds like you need to implement a single sketch which checks several inputs and then changes several outputs depending upon their status. With the Arduino running at 16 MHZ, it has plenty of time to check and update many pins thousands of times a second.
The cunning and elegant way to do this would probably be to use a couple of arrays to hold your pin definitions but you have plenty of space so the brute-force way will work perfectly well.
I'm not sure whether you want the output to simply reflect the state of the input (ie to be on when the input relay is closed) or whether you want it to toggle (ie to change state each time there is a short pulse from the relay) For the former you want a sketch that goes along these lines (obviously this is only an outline and not a real sketch):
int inputA = 3;
int inputB = 4;
....
int inputX = X;
int outputA = 9;
int outputB = 10;
...
int outputX = Y;
delay(100) // Delay to avoid burning out your relays by switching a thousand times a second! Change this as you wish.
}
For a toggle sketch, you would declare a boolean (true/false) variable for each switch and change the state of that variable (stateA=!stateA;) each time the HIGH and then LOW was detected.