#define NUMELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#define ISPRESSED LOW
uint8_t pinsTL[] = {6, 7, 8};
uint8_t pinsPL[] = {9, 10, 10};
uint8_t pinsBtn[] = {2, 4};
void setup() {
Serial.begin(115200);
Serial.println(F("Test"));
for (uint8_t cnt = 0; cnt < NUMELEMENTS(pinsTL); cnt++)
{
pinMode(pinsTL[cnt], OUTPUT);
digitalWrite(pinsTL[cnt], HIGH);
}
for (uint8_t cnt = 0; cnt < NUMELEMENTS(pinsPL); cnt++)
{
pinMode(pinsPL[cnt], OUTPUT);
digitalWrite(pinsPL[cnt], HIGH);
}
for (uint8_t cnt = 0; cnt < NUMELEMENTS(pinsBtn); cnt++)
{
pinMode(pinsBtn[cnt], INPUT_PULLUP);
}
}
void loop() {
for (uint8_t cnt = 0; cnt < NUMELEMENTS(pinsBtn); cnt++)
{
if(digitalRead(pinsBtn[cnt]) == ISPRESSED)
{
Serial.print(cnt);
Serial.println(F(" Button is pressed"));
}
}
}