Hello all .
I am an electrician by trade and have never really gotten into the electronics side but have always looked longingly at arduino so when it came to building my house I decided to make my own switch plates with a 5v led halo for cool factor with momentary switches back to a central arduino using an 8 channel relay pcb to switch the AC voltage for the lighting.
The problem I have now is I haven't got the time to learn all I need to know to write the sketch and I need to move in and need my lights working.
I have mastered the downloading the debounced switch code but I need the same thing replicated 7 times so that input 1 switches relay 1 input 2 switches relay 2 and so on up to 7 till I have used up the 14 IO can any one help me with a sketch I can simply load on to get me running please ? .
Later on I plan to learn enough to start mastering push and hold to dim the lighting etc but right now I just need a sketch to get things working and can't seem to find any tutorial showing what I want to do.
Also I did read in my research it's possible to set the inputs so that a pull up or pull down resistor isn't needed how do I do that too.
Hello all .
possible to set the inputs so that a pull up or pull down resistor isn’t needed how do I do that too.
For a normally open push button switch. In setup() set the pinMode to INPUT_PULLUP and wire like this, omitting R1 (wire 5V (or Vcc) direct to digital in).
To save pins you could use an I2C port expander. The MCP23017 has 16 I/O pins (MCP23008 has 8 I/O) using 2 Arduino pins.
If you want someone to write code for you, post in the Gigs and Collaborations section. Expect to pay.
Rather than the relay board, which can be electrically noisy, a triac board would also do the job, which will also be suitabe for your PWM dimmers.
Example - https://www.amazon.co.uk/SainSmart-8-Channel-Arduino-Mega2560-Duemilanove/dp/B007F93PF6
However my concern would be the cables from the switches to the arduino, long distances, shielded ?, probably near or parallel to main cables, could make it very prone to interference that C1 in groundfungus diagram will not be able to cope with.
You should really not be using those hobby 8-relay boards for home lighting. Especially if all of your wires have to run back to that one board.
And you should have a manual override switch function anyway, so start off with working lights with proper mechanical switches that will actually pass code. Then adventure from there at your own risk and leisure.