I am programming for the RGB matrix from adafruit and using arduino uno to control the matrix .
I stucked in programming part and I need help.
My problem.
I am illuminating the four corners of the LED matrix one after one so,
I am using if function so, if condition is true then perform the operation and if the condition is not true then keep all LEDs off.
and also using switch case inside the if.
so when the if condition is true it jumps to check the switch case
if the switch case is 00 then it light up the first corner
if the switch case is 01 then it light up the second corner
if the switch case is 10 then it light up the third corner
if the switch case is 11 then it light up the fourth corner
but it is now working in a way in which I expecting, I have pasted code below , so if some one can help me then it would be better for me.
and later on I am using labview to send the HIGH and LOW value for the if condition and
00 , 01, 10, 11 for the switch case .
#include <Adafruit_GFX.h>
#include <RGBmatrixPanel.h>
#define CLK 8 // USE THIS ON ARDUINO UNO, ADAFRUIT METRO M0, etc.
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3
#define ledPin 0
#define pinNumber 13 // pin defined to get the byte of signal
int val = 0;
byte FrameNumber = 0;
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
void setup() {
matrix.begin();
Serial.begin(115200);
pinMode(ledPin,INPUT); // sets the digital pin 0 as INPUT// put your setup code here, to run once:
}
void loop()
{
val = digitalRead (ledPin);
if(val == HIGH)
{
while(val== HIGH);
}
int inByte = Serial.read();
switch (inByte)
{
case 0:
matrix.fillRect(0, 0, 16, 16, matrix.Color333(7, 7, 7));
delay(1000);
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 0, 0));
delay(1000);
break;
case 1:
matrix.fillRect(0, 16, 16, 32, matrix.Color333(7, 7, 7));
delay(1000);
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 0, 0));
delay(1000);
break;
case 2:
matrix.fillRect(16, 16, 32, 32, matrix.Color333(7, 7, 7));
delay(1000);
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 0, 0));
delay(1000);
break;
case 3:
matrix.fillRect(16, 0, 32, 16, matrix.Color333(7, 7, 7));
delay(1000);
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 0, 0));
delay(2000);
break;
}
if(ledPin == LOW)
{
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 0, 0));
delay(2000);
}
}
My code.
if condtion true
then check the switch case
if switch case 00 then light up first corner
break
if switch case 01 then light up second corner
break
if switch case 10 then light up third corner
break
if switch case 11 then light up forth corner
break
if condtion false
all LEDs will be off