Hi
My project we have a p5 32 x 32 RGB Panel which sits on a window
in the office i have 2 Momentary SPST buttons with LED's one red, one green.
What i want is when i press the green button the RGB lights GREEN and the buttons LED lights up. When i Press the red button the RGB lights RED and the buttons LED lights up.
Im using the Adafruit RGB Matrix Panel Library.
the RGB panel will happily display and colour I send to it
When i create the button states they both work perfectly however when i add the else command to turn the screen off instantly the Greenstate changes to flickering rather then on. red works perfectly. any assistance would be great.
#include <RGBmatrixPanel.h>
#define CLK 11
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3
const int greenbutton = 53;
const int greenled = 51;
const int redbutton = 52;
const int redled = 50;
int greenState = 0;
int redState = 0;
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
void setup() {
pinMode(greenbutton, INPUT);
pinMode(redbutton, INPUT);
pinMode(greenled, OUTPUT);
pinMode(redled, OUTPUT);
//START UP
matrix.begin();
// fix the screen with green
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 7, 0));
delay(500);
// fix the screen with red
matrix.fillRect(0, 0, 32, 32, matrix.Color333(7, 0, 0));
delay(500);
// fill the screen with 'black'
matrix.fillScreen(matrix.Color333(0, 0, 0));
}
void loop() {
greenState = digitalRead(greenbutton);
redState = digitalRead(redbutton);
if (greenState == HIGH) {matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 7, 0)); digitalWrite (greenled, HIGH);}
if (redState == HIGH) {matrix.fillRect(0, 0, 32, 32, matrix.Color333(7, 0, 0)); digitalWrite (redled, HIGH);}
else {matrix.fillScreen(matrix.Color333(0, 0, 0));}
}