# Code checking before programming

**URL:** <https://forum.arduino.cc/t/code-checking-before-programming/521560>\
**Category:** General Guidance\
**Created:** [April 20, 2018, 11:34pm UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560 "2018-04-20T23:34:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 20, 2018, 11:34pm UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/1 "2018-04-20T23:34:39Z")

</div>

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.

```cpp
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;
}
}

```

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 21, 2018, 12:01am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/2 "2018-04-21T00:01:11Z")

</div>

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 encoder

int brightnessRed = 120; //Starting at half the value of full brightness  
Could be  
byte brightnessRed = 120; //Starting at half the value of full brightness

Depending 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.

---

<div class="post-metadata">

**Author:** ![lastchancename](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/lastchancename/32/215426_2.png) [@lastchancename](https://forum.arduino.cc/u/lastchancename)\
**Post date:** [April 21, 2018, 12:09am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/3 "2018-04-21T00:09:21Z")

</div>

Overall, you could drastically shorten & simplify your code with arrays.  
Also remember LEDs are not linear, you may want a table in PROGMEM to map your brightness value to PWM value.

---

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 21, 2018, 12:17am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/4 "2018-04-21T00:17:44Z")

</div>

> lastchancename:  
> Overall, you could drastically shorten & simplify your code with arrays.  
> Also remember LEDs are not linear, you may want a table in PROGMEM to map your brightness value to PWM value.

> 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 encoder
> 
> int brightnessRed = 120; //Starting at half the value of full brightness  
> Could be  
> byte brightnessRed = 120; //Starting at half the value of full brightness
> 
> Depending 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.

Both are excellent suggestions. As I don't know how to write arrays I'm probably going to leave that one alone. For simplicity purposes anyway. I will have to research the PROGMEM commands as that is above my head right now, but certainly worth looking into.

I do have a build station with soldering iron and all, but my daughter is 4, so she wont be handling any of that. Just figured I would build her a toy that can teach colors.

I'll be putting together the loop function tonight but needed to make sure what I have so far is a solid foundation (for a beginner anyway)

I appreciate the help

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 21, 2018, 12:37am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/5 "2018-04-21T00:37:26Z")

</div>

Maybe have a potentiometer the can be adjusted to create a 'divisor'.

It would be used to divide into all three: R, G and B values to set brightness/intensity.

---

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 21, 2018, 12:44am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/6 "2018-04-21T00:44:22Z")

</div>

> 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 encoder
> 
> int brightnessRed = 120; //Starting at half the value of full brightness  
> Could be  
> byte brightnessRed = 120; //Starting at half the value of full brightness
> 
> Depending 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...

```arduino
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:

```arduino
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?

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 21, 2018, 12:58am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/7 "2018-04-21T00:58:37Z")

</div>

An 'unsigned char' is a 'byte'.

Since 'brightnessRed' will not be larger than 255, this could also be 'byte'

Keeping a variable's 'type' small helps save RAM, however, I suppose in this small project RAM usage will not be a problem.

It’s just good practise.

'byte' and 'char' one byte  
'int' two bytes.  
'long' four bytes

BTW  
pinMode(pin\_A1, INPUT); \<———\<\<\<\< at power up, inputs are already set to INPUT

---

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 21, 2018, 1:33am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/8 "2018-04-21T01:33:42Z")

</div>

> larryd:  
> An 'unsigned char' is a 'byte'.
> 
> Since 'brightnessRed' will not be larger than 255, this could also be 'byte'
> 
> Keeping a variable's 'type' small helps save RAM, however, I suppose in this small project RAM usage will not be a problem.
> 
> It’s just good practise.
> 
> 'byte' and 'char' one byte  
> 'int' two bytes.  
> 'long' four bytes
> 
> BTW  
> pinMode(pin\_A1, INPUT); \<———\<\<\<\< at power up, inputs are already set to INPUT

Great to know! Thank you for the help.

So basically all of this,

```arduino
  pinMode(pin_A1, INPUT);
  pinMode(pin_B1, INPUT);
  pinMode(pin_A2, INPUT);
  pinMode(pin_B2, INPUT);
  pinMode(pin_A3, INPUT);
  pinMode(pin_B3, INPUT);

```

Useless code

---

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 21, 2018, 1:45am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/9 "2018-04-21T01:45:08Z")

</div>

So this should look a little cleaner as a foundation,

```cpp
unsigned long currentTime;
unsigned long loopTime;
int fadeAmount = 5;  //incremental increase or decrease in LED brightness
byte brightnessRed = 120; //Starting at half the value of full brightness
byte brightnessGreen = 120;//Starting at half the value of full brightness
byte brightnessBlue = 120;//Starting at half the value of full brightness
byte encoder_A1;
byte encoder_B1;
byte encoder_A2;
byte encoder_B2;
byte encoder_A3;
byte encoder_B3;
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
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);
  currentTime = millis();
  loopTime = currentTime;
}
}

```

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 21, 2018, 1:48am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/10 "2018-04-21T01:48:55Z")

</div>

"Useless code"  
Yes, not needed, but then again, it does document things 😉

If you used the internet pull-up resistors, you would need:

```cpp
  pinMode(pin_A1, INPUT_PULLUP);
  pinMode(pin_B1, INPUT_PULLUP);
  pinMode(pin_A2, INPUT_PULLUP);
  pinMode(pin_B2, INPUT_PULLUP);
  pinMode(pin_A3, INPUT_PULLUP);
  pinMode(pin_B3, INPUT_PULLUP);

```

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [April 21, 2018, 1:52am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/11 "2018-04-21T01:52:31Z")

</div>

Use descriptive variable names. You shouldn't need comments to explain what they mean. If the pin is for the red encoder then just say so in the variable name.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 21, 2018, 1:53am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/12 "2018-04-21T01:53:37Z")

</div>

int fadeAmount = 5; this could be 'byte' if the sketch keeps fadeAmount 0-255

unsigned char encoder\_A1\_prev=0; these could also be 'byte'

Looks like your daughter is going to be a programmer.

Edit  
Not sure you saw this:

Maybe have a potentiometer the can be adjusted to create a 'divisor'.  
It would be used to divide into all three: R, G and B values to set brightness/intensity.

---

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 21, 2018, 2:38am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/13 "2018-04-21T02:38:36Z")

</div>

> pert:  
> Use descriptive variable names. You shouldn't need comments to explain what they mean. If the pin is for the red encoder then just say so in the variable name.

The comments help keep me organized as I am a beginner but I do get what you mean.

> larryd:  
> int fadeAmount = 5; this could be 'byte' if the sketch keeps fadeAmount 0-255
> 
> unsigned char encoder\_A1\_prev=0; these could also be 'byte'
> 
> Looks like your daughter is going to be a programmer.
> 
> Edit  
> Not sure you saw this:
> 
> Maybe have a potentiometer the can be adjusted to create a 'divisor'.  
> It would be used to divide into all three: R, G and B values to set brightness/intensity.

I did see that, I do have a potentiometer, but not three. Thus the use of the encoder.

So basically the simplified version of the setup would look like

```arduino
unsigned long currentTime;
unsigned long loopTime;
byte fadeAmount = 5;  //incremental increase or decrease in LED brightness
byte brightnessRed = 120; //Starting at half the value of full brightness
byte brightnessGreen = 120;//Starting at half the value of full brightness
byte brightnessBlue = 120;//Starting at half the value of full brightness
byte encoder_A1;
byte encoder_B1;
byte encoder_A2;
byte encoder_B2;
byte encoder_A3;
byte encoder_B3;
byte encoder_A1_prev=0;
byte encoder_A2_prev=0;
byte encoder_A3_prev=0;
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

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);
  currentTime = millis();
  loopTime = currentTime;
}
}

```

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 21, 2018, 3:03am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/14 "2018-04-21T03:03:28Z")

</div>

Looking good.

> I do have a potentiometer, but not three.

You only need one.

You would read the value of the pot.  
Then 'map' the reading to a reasonable range.  
Then divide the values of all three R G B by the mapped value.  
Maybe the mapping could be 0-1023 to 1-5

Example:  
Let’s say the pot was set to center, the reading would be 512.  
The let’s say you 'map' 512 to 2  
Let’s say R=100 G=50 and B=80  
Then after dividing R G B by 2 would give: R=50 G=25 and B=40  
Therefore the same colour but less bright.

---

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 21, 2018, 3:14am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/15 "2018-04-21T03:14:16Z")

</div>

> larryd:  
> Looking good.
> 
> You only need one.
> 
> You would read the value of the pot.  
> Then 'map' the reading to a reasonable range.  
> Then divide the values of all three R G B by the mapped value.  
> Maybe the mapping could be 0-1023 to 1-5
> 
> Example:  
> Let’s say the pot was set to center, the reading would be 512.  
> The let’s say you 'map' 512 to 2  
> Let’s say R=100 G=50 and B=80  
> Then after dividing R G B by 2 would give: R=50 G=25 and B=40  
> Therefore the same colour but less bright.

I think that would be awesome to do. Ideally what I'm trying to accomplish is the three knobs having their own individual value, R, B, G, so my 4 year old can learn what mixing the colors does. A little bit of blue and green makes yellow, red and blue make purple, all three make white, etc.

Just an educational toy.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 21, 2018, 3:24am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/16 "2018-04-21T03:24:34Z")

</div>

> Just an educational toy.

No no no :o

This will lead to something much bigger as she grows up! 🙂

BTW  
There are things called neopixels that might be better to use.

![](https://europe1.discourse-cdn.com/arduino/original/4X/2/3/4/234c5323fa871afaec89e17c9ea9807fe4ac2037.jpeg)

---

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 21, 2018, 3:46am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/17 "2018-04-21T03:46:33Z")

</div>

> larryd:  
> No no no :o
> 
> This will lead to something much bigger as she grows up! 🙂
> 
> BTW  
> There are things called neopixels that might be better to use.
> 
> ![](https://europe1.discourse-cdn.com/arduino/original/4X/2/3/4/234c5323fa871afaec89e17c9ea9807fe4ac2037.jpeg)

Got it but i'm not there yet with her. Just need to focus on this one and take it step by step. Shes 4. She wants crayons and world peace.

---

<div class="post-metadata">

**Author:** ![CrossRoads](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/crossroads/32/214033_2.png) [@CrossRoads](https://forum.arduino.cc/u/CrossRoads)\
**Post date:** [April 21, 2018, 3:49am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/18 "2018-04-21T03:49:08Z")

</div>

Neopixel, or WS2812B,  
Spartkfun carries them as thru hole LEDs also if you don't want to deal with SMDs.

> **[LED - RGB Addressable, PTH, 5mm Diffused (5 Pack) - COM-12986 - SparkFun...](https://www.sparkfun.com/products/12986)**
>
> We know these look like a lot of our other LEDs, but they're not! These are PTH Addressable RGB LEDs with a WS2812 (or "NeoPixel") control IC built right i

or a flatter top,

> **[LED - RGB Addressable, PTH, 5mm Clear (5 Pack) - COM-12999 - SparkFun...](https://www.sparkfun.com/products/12999)**
>
> We know this looks like a lot of our other LEDs, but it's not! This is a PTH Addressable RGB LED with a WS2812 (or "NeoPixel") control IC built right into

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [April 21, 2018, 4:06am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/19 "2018-04-21T04:06:32Z")

</div>

> mgttrottier:  
> The comments help keep me organized as I am a beginner but I do get what you mean.

Comments are great. Definitely use lots of comments. But you wouldn't want to have the same comment explaining what a variable is for everywhere you use it, that's why you should use descriptive variable names so you don't have to think for a second "Now which color was A?".

> CrossRoads:  
> or a flatter top,  
> [LED - RGB Addressable, PTH, 5mm Clear (5 Pack) - COM-12999 - SparkFun Electronics](https://www.sparkfun.com/products/12999)

I like that "straw hat" style of LED but I think a bare non-diffused LED would be confusing because you still see too much of each individual color. If there will be some external diffuser added that would be fine (you still don't get as good of color mixing in my experience but it's not too bad) but I haven't read anything here about a diffuser.

---

<div class="post-metadata">

**Author:** ![mgttrottier](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mgttrottier](https://forum.arduino.cc/u/mgttrottier)\
**Post date:** [April 21, 2018, 4:20am UTC](https://forum.arduino.cc/t/code-checking-before-programming/521560/20 "2018-04-21T04:20:26Z")

</div>

Love the suggestions, and I will most certainly look into addressable LEDs for future projects. But to steer back to what the point was...

Is this a viable base code for using three encoders to control a common cathode RGB LED?

Again, Im trying to do the good father thing and teach her how colors mix. I certainly do appreciate the education I can receive, but this is just a simple toy for a four year old her dad built.

Leonardo board, three cts encoders, 1 common cathode RGB led, that's it.

I'm a beginner, i'm a network security expert, not a programmer. I'm learning....

[Next page](https://forum.arduino.cc/t/code-checking-before-programming/521560.md?page=2)
