Button to change led effect

Hi to all,

My setup is like the following :

Hardware

  1. 232 Leds (WS2812B)
  2. AC 5v/20A
  3. Arduino uno
  4. Potentiometer
  5. Button
  6. lcd screen
  7. resistor 330oh

These are connected like this :

And i use the following code :

Attached (more than 9000k characters

The main idea :

Button will change the effect of leds and potentiometer A0 will setup the brightness. Led screen will display which effect is selected and what is the brightness.

The code include another potentiometer A1 to control Hue value but at the moment is not connected as i do not have second potentiometeravailable.

The problem :

Leds are light up , but when i push the button , lcd screen switch off and then back on on , effect change but sometimes "freeze" and not show the correct values of potentiometer and selected effect. Or even effect not change at all....

If someone can help will be great.

Best regards

AllEffects_Tree.ino (32.2 KB)

You show the 5 V connected to the Arduino "barrel jack". That is useless. It should connect to the "5V" pin - but for a UNO you must disconnect it when connected to a PC USB for programming.

I cannot imagine why your source code is so long. :roll_eyes:

I have written in other references to WS2812 strips how the wiring should be laid out.

Paul__B:
You show the 5 V connected to the Arduino "barrel jack". That is useless. It should connect to the "5V" pin - but for a UNO you must disconnect it when connected to a PC USB for programming.

Do you mean that to power up the arduino direct from the AC, i should not give power from AC to Arduino "barrel jack" but to pin 5 ?
I am very new to this and i did not read or see something like this before.
Can you please provide any reference for this to help me understand it better?
And how does this has to do with the button press issue?
Code is long i know , i will focus to rewrite it - improve it after finishing with the circuit

If you supply 5V DC into the barrel jack, it goes thru a reverse polarity diode, then the 5V voltage regulator, before the processor chips sees it. At that point it is not 5V anymore.
5VDC from external source needs to supplied to the USB connector, or to 5V on the power header.

Some (most?) PCs do not like having DC back-driven into the USB port, so you may need to disconnect 5V from the power header while programming. Mine complains of a power surge and shuts down the USB port.

Your use of the term "AC" for the power supply is disconcerting. It should be unequivocal that you are using a regulated DC power supply of 5 V to power the LED strip and the Arduino. That will generally be a power supply derived from the AC mains, but that is not how you should refer to it. :grinning:

Unfortunately, the rather old and unhelpful "tutorials" and product descriptions on the main Arduino site - which has at this moment been inconveniently offline for a couple of days - refer to powering various Arduinos by the "barrel jack" or "Vin" and using the internal regulator, from 7 to 12 V. The regulator on the Arduino UNO/ Nano/ Pro Mini/ Mega2560/ Leonardo/ Pro Micro has very little heatsink, so will not pass very much current (depending on the input voltage and thus, how much voltage it has to drop) before it overheats and (hopefully reversibly) shuts down. It is essentially a novelty provided in the very beginning of the Arduino project when "9V" power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.

Nowadays, 5 V regulated switchmode packs are arguably the most readily available in the form of "Phone chargers" and switchmode "buck" regulators to regulate down from 12 V or other available voltages are cheap on eBay so these can be fed into the USB connector or (more appropriately) 5 V pin to provide adequate power for most applications. In your case you are using a substantially more capable power supply again. Unfortunately, many tutorials or "instructables" are seriously outdated or misleading and have not been updated to reflect the contemporary situation.

CrossRoads has pointed out the problem with having the "5V" pin on the UNO connected to a power supply while connected to a PC USB port for programming. This is actually not a problem with the Nano which is cheaper, more compact and the more practical and preferred version to use for most projects. :sunglasses:

Thank you both for your suggestions, i change the connection to power up the Arduino direct to "5V" pin, but the issue with the button and screen remain.

OK, well I cannot help much further as I am not keen to load your code (as it means running the IDE). Sorry!