Hey all,
I havn't played around in a while but I think I still remember the basics. Basically I'm building a common cathode RGB that is controlled by three encoders, each red, green, blue. Teaching my 4 year old the primary colors. (Leonardo Board, CTS 288 encoders, and a three common cathode RGB LEDs on a bus strip)
I believe I have the setup correct but if one of the amazing people here can check it over for me that would be greatly appreciated. Remembering the coding is going to be the hard part, but at least I want to make sure my roots that i'm building the code on are good.
int brightnessRed = 120; //Starting at half the value of full brightness
int brightnessGreen = 120;//Starting at half the value of full brightness
int brightnessBlue = 120;//Starting at half the value of full brightness
int fadeAmount = 5; //incremental increase or decrease in LED brightness
unsigned long currentTime;
unsigned long loopTime;
const int pin_A1 = 2;//A pin red encoder
const int pin_B1 = 3;//B pin red encoder
const int pin_A2 = 4;//A pin green encoder
const int pin_B2 = 5;//B pin green encoder
const int pin_A3 = 6;//A pin blue encoder
const int pin_B3 = 7;//B pin Blue encoder
const int LED_Red = 11;//Has to be set as output
const int LED_Green = 10;//Has to be set as output
const int LED_Blue = 9;//Has to be set as output
unsigned char encoder_A1;
unsigned char encoder_B1;
unsigned char encoder_A2;
unsigned char encoder_B2;
unsigned char encoder_A3;
unsigned char encoder_B3;
unsigned char encoder_A1_prev=0;
unsigned char encoder_A2_prev=0;
unsigned char encoder_A3_prev=0;
void setup()
{
Serial.begin(9600); //Can add Serial.println later to each section
pinMode(LED_Red, OUTPUT);
pinMode(LED_Green, OUTPUT);
pinMode(LED_Blue, OUTPUT);
pinMode(pin_A1, INPUT);
pinMode(pin_B1, INPUT);
pinMode(pin_A2, INPUT);
pinMode(pin_B2, INPUT);
pinMode(pin_A3, INPUT);
pinMode(pin_B3, INPUT);
currentTime = millis();
loopTime = currentTime;
}
}
