Whenever I run my code the if statement of lines 58-67 change the variable "SELECT1" to always be 1. If I take that section of code out I don't have the issue, but the arrays I want copied obviously wont copy. I've also tried a for loop and have looked everywhere for answers. Please help :
//define colors RGB
int RED[3] = {50, 0, 0};
int ORANGE[3] = {50, 30, 30};
int YELLOW[3] = {50, 30, 30};
int GREEN[3] = {0, 50, 0};
int BLUE[3] = {0, 0, 50};
int PURPLE[3] = {25, 0, 25};
int WHITE[3] = {50, 50, 50};
//define pins
//color pins
int RLED = 3;
int GLED = 5;
int BLED = 6;
//Button analog pin = A1
int BUTTON = 0;
int SELECT0 = 1;
int SELECT1 = 1;
// COLOR0 is current color, COLOR1 is next color
int COLOR0[3] = {0, 0, 0};
int COLOR1[3] = {0, 0, 0};
int COLOR2[3] = {0, 0, 0};
void setup() {
//Start serial communication
Serial.begin(9600);
//start pins
pinMode(RLED, OUTPUT);
pinMode(GLED, OUTPUT);
pinMode(BLED, OUTPUT);
pinMode(A1, INPUT_PULLUP);
//
}
int BUTTON_SELECT()
{
BUTTON = analogRead(A1);
if (BUTTON > 0 && BUTTON < 35)
SELECT1 = 1;
else if (BUTTON > 55 && BUTTON < 90)
SELECT1 = 2;
else if (BUTTON > 100 && BUTTON < 130)
SELECT1 = 3;
else if (BUTTON > 145 && BUTTON < 175)
SELECT1 = 4;
else if (BUTTON > 190 && BUTTON < 205)
SELECT1 = 5;
SELECT0 = SELECT1;
return SELECT1;
}
void loop() {
//changes color based on button //DEBUG
SELECT1 = BUTTON_SELECT();
if (SELECT1 = 1)
memcpy(COLOR1, WHITE, sizeof(COLOR1));
else if (SELECT1 = 2)
memcpy(COLOR1, WHITE, sizeof(COLOR1));
else if (SELECT1 = 3)
memcpy(COLOR1, WHITE, sizeof(COLOR1));
else if (SELECT1 = 4)
memcpy(COLOR1, WHITE, sizeof(COLOR1));
else if (SELECT1 = 5)
memcpy(COLOR1, WHITE, sizeof(COLOR1));
//DEBUG
//prints debugging info
Serial.println(BUTTON);
Serial.print("SELECT 1 :");
Serial.println(SELECT1);
Serial.print("SELECT 0 :");
Serial.println(SELECT0);
delay(500);
//sets LED color
analogWrite(RLED, COLOR1[0]);
analogWrite(GLED, COLOR1[1]);
analogWrite(BLED, COLOR1[2]);
}
Table_LED2.ino (1.81 KB)