larryd:
unsigned char encoder_A1;
Could be
byte encoder_A1;const int pin_A1 = 2;//A pin red encoder
Could be
const byte pin_A1 = 2;//A pin red encoderint brightnessRed = 120; //Starting at half the value of full brightness
Could be
byte brightnessRed = 120; //Starting at half the value of full brightnessDepending on the wiring, you may be able to turn on pull-ups.
You will of course need a loop() function.
You need to get the better half buy your child a soldering iron, DVM, hand tools, drill etc.
So if I understand correctly in functionality of the project, changing it to this...
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 byte pin_A1 = 2;//A pin red encoder
const byte pin_B1 = 3;//B pin red encoder
const byte pin_A2 = 4;//A pin green encoder
const byte pin_B2 = 5;//B pin green encoder
const byte pin_A3 = 6;//A pin blue encoder
const byte pin_B3 = 7;//B pin Blue encoder
const byte LED_Red = 11;//Has to be set as output
const byte LED_Green = 10;//Has to be set as output
const byte LED_Blue = 9;//Has to be set as output
byte encoder_A1;
byte encoder_B1;
byte encoder_A2;
byte encoder_B2;
byte encoder_A3;
byte 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;
}
will keep the 8 bytes of information needed and not load up like a const int will.
In terms of this part of the code:
unsigned char encoder_A1_prev=0;
unsigned char encoder_A2_prev=0;
unsigned char encoder_A3_prev=0;
Does it have to remain an unsigned char since the event of the encoder moving forward or backward has already happened and is just being compared to?