Hello everyone,
Ive been banging my head against the wall trying to write a program (im a very amateur coder ( ) for an arduino controlled 48-relay board consisting of 3 16-relay modules, an Arduino mega 2560 and a W5100 ethernet shield.
I was successful mimicking a few instructables such as this one which is sadly for a maximum of 10 relays, but Im having trouble adapting this code for 48 outputs, so my questions are:
1- Are there enough pins to control all 48 relays? My pin array is { 2, 3, 5, 6, 7, 8, 9, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, A0, A1, A2, A3, A4, A5, A7, A8, A9, A12, A13, A14, A15 }
Or am I wrong in using the analog pins as output? Ive googled plenty and finally decided to opt out on using pins 4, 10, 11, 12 ,13, 50, 51, 52, and 53 because im not sure if they are usable in my case or not. Can you shed some light on what pins I must steer clear of and what pins are good?
2- Since my pins are not a normal sequence, I cant use a regular “for loop” (this is the major coding problem for me) and I don’t quite understand how the buttons are being printed and the output status is being checked. The best I could come up with is the following:
char relayPins[] = { 2, 3, 5, 6, 7, 8, 9, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, A0, A1, A2, A3, A4, A5, A7, A8, A9, A12, A13, A14, A15};
int relayCount = 48;
for (int thisPin =0; thisPin < pinCount; thisPin++) {
pinMode(relayPins[thisPin], OUTPUT);
}
Perhaps if I omit the analog pins, I can declare this array as int. this probably would work for setting the pinMode, but is trickier for printing the buttons. any ideas?
3- Im using a 12V-1A external power adapter to power both the relays and the Arduino+shield, do I need more juice?
I don’t need the code to be fancy, I just need it to work, even If I have to manually repeat some lines 48 times.
I realize it’s a lot to ask, but im desperate. Help!