Bear with me as I'm fairly adept at C# but I am having a problem understanding how to get an array iterated.
I am writing a program to test relay boards, it will eventually have an input mechanism to select the number of relays on the board. For now, i just need to get an array iterated to move on with the code.
The biggest relay board I've seen has 16 relays, so....
#define Relay1 2 // Arduino Digital I/O pin numbers for UNO R3
#define Relay2 3
#define Relay3 4
#define Relay4 5
#define Relay5 7
#define Relay6 8
#define Relay7 9
#define Relay8 10
#define Relay9 11
#define Relay10 12
#define Relay11 13
#define Relay12 A0
#define Relay13 A1
#define Relay14 A2
#define Relay15 A3
#define Relay16 A4
int relays[]{ Relay1,Relay2,Relay3,Relay4,
Relay5,Relay6,Relay7,Relay8 };
int maxRelayCount = 8;
char rx_byte = 0;
void setup() //Initializes all variables and settings
{
Serial.begin(9600);
// create an input for the amount of relays on the board
//hardcoded for now
//Set pins to OFF & declare pins as OUTPUTS
for(int i = 0; i < maxRelayCount; i++)
{
digitalWrite(relays[i], RELAY_OFF);
pinMode(relays[i], OUTPUT);
//How to convert i to a string in c++?
//Serial.print("Relay " +[i] + " set HIGH and as OUTPUTS");
}
//Check that all relays are inactive at Reset
delay(4000);
}
So there are two issues. If I remove the loop and just hard code 8 times to set HIGH and OUTPUT it works fine, but the loop does not and won't upload to the Arduino, thus the reason I believe it is wrong. Secondary question is how to convert the counter i to a string to concatenate the message