Thank You for so much help!
Quote from: mrozny on August 12, 2011, 09:56:26 AM
2. I will have 20 Digital Inputs and 20 Digital Outputs.
My inputs will be controlling by switches which will give 5VDC or 0VDC to inputs
Will the switches actually supply 5V, or will they be just a switch that connects the two wires?
Switches will be connected to 24V and they will give signal to relay which will active 5VDC or 0VDC to input.
I am planning to use http://www.sparkfun.com/products/9346
I hope I will have enough space to connect everything there..
So lets say that I would like to resign from pull-up resistors and 100 ohm resistors.
I have this code:
const int switch1 = 2;
const int switch2 = 3;
const int light1 = 4;
const int light2 = 5;
void setup() {
pinMode(switch1, INPUT);
pinMode(switch2, INPUT);
pinMode(light1, OUTPUT);
pinMode(light2, OUTPUT);
}
void loop() {
if (digitalRead(switch1) == HIGH & digitalRead(switch2) == HIGH) {
digitalWrite(light1, HIGH);
digitalWrite(light2, HIGH);
}
}
And I am planning to change it for that one where I am using internal pull-up resistors:
const int switch1 = 2;
const int switch2 = 3;
const int light1 = 4;
const int light2 = 5;
int state1 ;
int state2;
void setup() {
pinMode(switch1, INPUT);
pinMode(switch2, INPUT);
pinMode(light1, OUTPUT);
pinMode(light2, OUTPUT);
}
void loop() {
digitalWrite(light1, LOW);
state1 = digitalRead(switch1);
digitalWrite(switch2, LOW);
state2 = digitalRead(switch2);
if (state1 == 1 & state2 == 1) {
digitalWrite(light1, HIGH);
digitalWrite(light2, HIGH);
}
}
Is that ok? As I doubt of it but I have no idea how to do it different..
Quote from: mrozny on August 12, 2011, 09:56:26 AM
3. I am assuming that when I connect Arduino output directly to 5VDC relay it is possible to control it or maybe I will need transistor before?
It depends on how much current the relay coil will draw. Up to 40mA, you don't strictly need a transistor. More thatn 40mA, then you will definitely need a transistor. It's a good idea to use one anyway, even if the current is lower that 40mA. Always use a diode across the relay coil -- if you don't, the back-EMF high voltage spikes will destroy your circuit.
Connecting a Relay to Arduino | Simple circuit to connect a … | Flickr
Thank You for this advice. Now I am planning to use A 1N914 Signal Diode to protect against "Back emf". Is that diode
ok? The picture in link is not loading. I am assuming that for each output I am connecting this diode between relay and output. Each output has got its own diode..
Let's say that I would like to use transistor - is that mean that for each output I need one transistor?
Which I should use then and how to connected it with my diode, relay, and output..
Quote
Quote from: mrozny on Today at 04:56:26 AM
- I will power my board from 12VDC - I am assuming that I should connect it to VIN port and ground to Arduino ground
Yes, that's correct, 12V to VIN and Ground.
You can also supply power using the barrel-jack, then you also get the protection of the reverse polarity diode.
If the 12V is not being used elsewhere, you could go with a 7.5V wallwart such as dipmicro.com carries, and you will not be wasting so much energy heating up the regulator.
I am planning to supply my board with 12VDC or 24VDC which will go through first switch than diode 1N4001 and LM7812 with capacitors
and from that to my board. I am planning also to use fan which eliminate heat from LM7812.
Sounds ok?