I want to know how I can use case statement for each array.
Below is my code:
int incomingByte = 0;
void setup()
{
Serial.begin(115200);
for (int thisPin = 2; thisPin < 6; thisPin++)
{
pinMode(thisPin, OUTPUT);
}
}
void loop()
{
int button1[] = {0xFF, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05};
int button2[] = {0xFF, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06};
int button3[] = {0xFF, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08};
int button4[] = {0xFF, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C};
if (Serial.available() > 0)
{
incomingByte = Serial.read();
}
switch (incomingByte)
{
case button1:
digitalWrite(2, HIGH);
break;
case button2:
digitalWrite(3, HIGH);
break;
case button3:
digitalWrite(4, HIGH);
break;
case button4:
digitalWrite(5, HIGH);
break;
default:
for (int thisPin = 2; thisPin < 6; thisPin++)
{
digitalWrite(thisPin, LOW);
}
}
}