sketch upload ok to mega 2560 board. but not doing what I intent to.

Hi! everyone Im new to programming and have read a lot trying to learn, but I want to control a LED RGB strip I Wrote the code to turn on the LEDS and it works ok, but when trying to add an if …else statement to turn the LEDs on and OFF it does compile and uploads to the board but do nothing.

the code Im using is in the attached PDF file

Thank You! for your help.

myledtest.pdf (63.3 KB)

First of All, you can add Code to this Page with [ Code] directive.

Second, what I See is, your LED works only if outton state is high. Which means, when you keep Pressed the Button, then the LED should Show up.

Third, are you sure about button==high? If default, the Pins have a pullup resistor which means high = Button unpressed, Low = Button Pressed.

Please confirm.

Your solution: fix high low
Create a variable for toggleLight and a Debounce for Button (search the forum, there are Tons of examples)
Pull out the LED code and query if the toggleLight is true.

jabreu0:
the code Im using is in the attached PDF file

Thank You! for your help.

Please don’t post code in a PDF file. Ideally just include the code in your post using the code button </> and if it is too long for that (I hope not) then add your .ino file as an attachment.

See How to use the forum

…R