Hello, I have a problem with my if statement ignoring the requirement I gave it. When rgbstatus is 0 it'll just run the statement and the else after, and when rgbstatus is 1 it does the same. I would like for it to only run the else when rgbstatus is not 0 and run the if statement when rgbstatus is 0.
Complete code:
#define ROW_1 2
#define ROW_2 3
#define ROW_3 4
#define ROW_4 5
#define ROW_5 6
#define ROW_6 7
#define ROW_7 8
#define ROW_8 9
#define COL_1 10
#define COL_2 11
#define COL_3 12
#define COL_4 13
#define COL_5 A0
#define COL_6 A1
#define COL_7 A2
#define COL_8 A3
#define LED_G A4
#define LED_R A5
const byte rows[] = {
ROW_1, ROW_2, ROW_3, ROW_4, ROW_5, ROW_6, ROW_7, ROW_8
};
const byte col[] = {
COL_1, COL_2, COL_3, COL_4, COL_5, COL_6, COL_7, COL_8
};
// The display buffer
// It's prefilled with a smiling face (1 = ON, 0 = OFF)
byte ALL[] = {B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111};
byte EX[] = {B00000000, B00010000, B00010000, B00010000, B00010000, B00000000, B00010000, B00000000};
byte Frame1[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame2[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame3[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame4[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame5[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame6[] = {B00000000, B00100100, B00101010, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame7[] = {B00000000, B00100100, B00101010, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame8[] = {B00000000, B00100100, B00101010, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame9[] = {B00000000, B00100100, B00101010, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame10[] = {B00000000, B00100100, B00101010, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame11[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame12[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame13[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame14[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame15[] = {B00000000, B00100100, B00100100, B00000000, B01000010, B00111100, B00000000, B00000000};
byte Frame16[] = {B00000000, B00000000, B00000000, B00011000, B00011000, B00000000, B00000000, B00000000};
byte Frame17[] = {B00000000, B00000000, B00011000, B00100100, B00100100, B00011000, B00000000, B00000000};
byte Frame18[] = {B00000000, B00011000, B00100100, B01000010, B01000010, B00100100, B00011000, B00000000};
byte Frame19[] = {B00011000, B00111100, B01100110, B11000011, B11000011, B01100110, B00111100, B00011000};
byte Frame20[] = {B00111100, B01100110, B11000011, B10000001, B10000001, B11000011, B01100110, B00111100};
byte Frame21[] = {B01100110, B11000011, B10000001, B00000000, B00000000, B10000001, B11000011, B01100110};
byte Frame22[] = {B10000001, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B10000001};
byte Frame23[] = {B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000};
float timeCount = 0;
int rgbstatus = 0;
void setup()
{
// Open serial port
Serial.begin(9600);
// Set all used pins to OUTPUT
// This is very important! If the pins are set to input
// the display will be very dim.
for (byte i = 2; i <= 13; i++)
pinMode(i, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
}
void loop() {
if (rgbstatus = 1) {
delay(1);
timeCount += 1;
Serial.print(rgbstatus);
if (timeCount < 40) {
drawScreen(Frame6);
}
else if (timeCount < 270) {
drawScreen(Frame1);
}
}
else{
Serial.print(rgbstatus);
drawScreen(ALL);
}
}
void RGBLED() {
if (rgbstatus = 0) {
digitalWrite(A4, HIGH);
}
else {
digitalWrite(A5, HIGH);
}
}
void drawScreen(byte buffer2[])
{
// Turn on each row in series
for (byte i = 0; i < 8; i++) // count next row
{
digitalWrite(rows[i], HIGH); //initiate whole row
for (byte a = 0; a < 8; a++) // count next row
{
// if You set (~buffer2[i] >> a) then You will have positive
digitalWrite(col[a], (buffer2[i] >> a) & 0x01); // initiate whole column
delayMicroseconds(100); // uncoment deley for diferent speed of display
//delayMicroseconds(1000);
//delay(10);
//delay(100);
digitalWrite(col[a], 1); // reset whole column
}
digitalWrite(rows[i], LOW); // reset whole row
// otherwise last row will intersect with next row
}
}
Problems actually start at the void loop starting at line 77.
Thanks in advance.