Skip to main content
2 of 5
added 67 characters in body
  • Equality comparison in C and C++ is expressed by == operator. ==, not =. This

     if (wavecolor = 0) { 

actually assigns zero to your wavecolor variable, thus destroying the value you just read.

  • This is valid

     if (wavecolor > 0 or wavecolor < 333) 

but you might want to try using a more "canonical" form

 if (wavecolor > 0 || wavecolor < 333) 

or is an "alternative" form of || operator, introduced a long time ago for reasons that are obsolete today.

However, the common sense says that you actually need && here, which is and, not or.

  • In your conditions you managed to "exclude" such values as 333, 667 and 1022 - they don't match any of your conditions.

  • As a side note, in a single-file program all file-scope variables should be either const or static. In your case

     const int redpin = 6; const int greenpin = 3; const int bluepin = 5; const int potPin = 0;