Hi folks, I am trying to make a data structure of booleans to hold the status of all the IO pins. First time using struct as well as fairly new to pointers etc, so a little help to "point" me in the right direction is very much appriciated.
Is there a way to access a member of the data structure using a variable? I have 30 pins and would like them in a structure where they can be accessed when a request comes in over UPD (a whole other problem )
Please forgive my terrible coding! and shout at me for doing something daft...
struct pinInfo {
bool relay1;
bool relay2;
bool relay3;
}ioPins;
char *pinNames[3] = {"relay1", "relay2", "relay3"};
void setup() {
Serial.begin(9600);
ioPins.relay1 = false;
ioPins.relay2 = true;
ioPins.relay3 = false;
for (int i = 0; i <= 2; i++) {
Serial.println(ioPins.pinNames[i]); //compiler doesn't like this
}
}
I thought that the pinNames array would come in handy when responing to a UDP request allowing me to send a string pin name and its status.