3 Button Toggle RGB LED

HI, Trying to make three independent momentary NO switches control each color in RGB LED. The script runs but the switches do not control the on/off state of the RGB. The RED diode is turn on without pressing any button. At this point I am lost!

3_Button_RGB_LED_Toggle.ino (2.66 KB)

3_Button_RGB_LED_Toggle.ino (2.66 KB)

Can you post a schematic of your project?

If you post your code as described in the how to use this forum sticky more members will see it.

(deleted)

Did you modify the code? This line is really bizarre:

int Button = (13,12,8);

Hi, Want to use independent swithes to control the on/off state of the RGB LED. When the script runs the swithes do not control the RGB. It runs and the RED LED comes on without pressing and switch.

void loop()
{
  
  REDcurrentButton = debounce(REDlastButton);                //read debounced state
  if (REDlastButton == LOW && REDcurrentButton == HIGH);     //if it was pressed…
     {
     REDlastButton = REDcurrentButton;                       //toggle the LED value
     REDledOn = !REDledOn;
     REDlastButton = REDcurrentButton;
     digitalWrite(RLED,REDledOn);
    // return REDlastButton;                                   //return the current value
     } 
     
{
  
  GREENcurrentButton = debounce(GREENlastButton);            //read debounced state
  if (GREENlastButton == LOW && GREENcurrentButton == HIGH); //if it was pressed…
      {
      GREENlastButton = GREENcurrentButton;                  //toggle the LED value 
      GREENledOn = !GREENledOn;
      GREENlastButton = GREENcurrentButton;
      digitalWrite(GLED,GREENledOn);
     // return GREENlastButton;                                //return the current value
      }
       
{
  
  BLUEcurrentButton = debounce(BLUElastButton);             //read debounced state
  if (BLUElastButton == LOW && BLUEcurrentButton == HIGH); //if it was pressed…
      {
      BLUElastButton =  BLUEcurrentButton;                   //toggle the LED value 
      BLUEledOn = !BLUEledOn;
      BLUElastButton = BLUEcurrentButton;
      digitalWrite(BLED,BLUEledOn);
     // return BLUElastButton;                                 //return the current value
                                          
      }}}}

3_Button_RGB_LED_Toggle.ino (2.66 KB)

I've merged your cross-posts @ron_wells.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

When you post code post the entire sketch, please.

Sorry, new at this forum etiquette. Floating inputs hmm, should I assign logic levels to the dummy variables when the function is declared?

Your inputs are probably not floating, I see what looks like 10k ohm resistors in the photo you posted. On the other hand, you should respond to my post about the declaration, reply #3.

Thought Int = (13,12,8) should have been deleted. Also had a thought maybe my logic is reversed. Using a volt meter, measure 5v at each switch when not press and 0v when press?

@ron_wells, please don't PM me with technical questions. I've requested it in my forum signature.