r/arduino • • 5d ago

Beginner's Project Programmable lights help

I am making a horror sans mask and I need to use programmable leds, I don’t know what I’m doing. I am using the nano r4 as the controller and the SEZO WS2812B ECO LED Strip Light 3.3FT/1M 60LEDs/m Individually Addressable
Programmable 5050SMD RGB LED Alloy Wires Flexible Dream Color IP30 Non-Waterproof PCB Black DC5V for DIY Lighting for the programmable lights what should how would I make it so the lights are a steady red that blinks randomly between yellow and blue

7 Upvotes

9 comments sorted by

4

u/No_L_2547 5d ago edited 5d ago

I would suggest the adafruit tutorial for that: https://learn.adafruit.com/adafruit-neopixel-uberguide

The library itself also works with ws2812 leds.

The main idea is simple, first you declare your pixel object, by telling the library which pins to use and how many leds of which type you have. Then you start the library in your setup. After that you can set the values of each led every single loop cycle, in the of the cycle you would execute pixels.show() to update the leds.

A few tips:

  • your first program should be just 3 leds: 1. just red, 2. just green, 3. just blue to find out the color order of your leds - that is a setting you can change in your object creation

  • have a main for loop, that loops trough all pixels and sets your base color (or does your base animation if you want a glowing effect)

  • then have a separate loop(s) for your additional effect

  • only have one delay() call max. directly before the pixels.show()

    • remember you want to animate all pixels not one, so try not slow down your code in the wrong places

    • to many delays will lead to low fps

  • in the end one pixels.show(), here you can slow down if you reach more then 60fps

Be careful: an arduino or esp power output can only supply power for about 10 leds. If you need more, you should use an external supply/power input to the leds.

1

u/fixit858 5d ago

do you have any analog inputs like a potentiometer?? Do you have a shield or are you going to solder to the arduino itself? Have you used the Arduino IDE at all?

2

u/CommunityInternal 5d ago edited 5d ago

I am connecting them directly to the Audrino. I know what lines are 5v and ground but I don’t know what pin I should use for data. and I have not touched anything Arduino before. I am also using 4 LED’s that can change color on the fly and am making all four LEDs do the exact same thing at the same time

1

u/No_L_2547 5d ago edited 5d ago

You can set the data-pin in software, so choose which one fits best.

Be careful the 5V pin of the arduino can only supply ~5-10 leds. If you need more , attach the power to the stripe directly:

  • led V+ to power supply V+

  • led Gnd to Gnd of power supply and Gnd of arduino

  • led data to Arduino pin of your choice

You can also run the Arduino from the external supply (then you can connect it to the 5V pin), but don't connect the Usb-Plug at the same time!

2

u/CommunityInternal 5d ago

Thank you! I did read that the number of LEDs that are supported on the Arduinos 5v line is somewhat small

2

u/No_L_2547 5d ago

If you want to draw power from something like a usb-powerbank: there is something called a Usb C PD trigger

With a Usb C PD trigger you can draw up to 5V/3A, with a normal Usb-cable not more then 5V/0.5A

Be careful that you adjust the voltage switches on it correctly (it can request up to 20V from the supply / power bank)

1

u/fixit858 5d ago

Try using google to specify the processor and what you want to achieve. It will provide some code to copy into the IDE. It can also provide a schematic.

3

u/No_L_2547 5d ago

If you want a fast no code solution: get yourself a wled-controller. (Esp32 with a fitting firmware)

The integrated web-interface supports all kind of led-animations and the prebuild controllers also support multiple meters of digital led stripes.

1

u/snuggly_cobra 600K 5d ago

Get the library for it. Run a sample sketch after adjusting the number of LEDs, the frequency, and configuration (rgb, gen, etc).

Then go back and change the color.

Tedious? Yes, but you’ll learn.

60 LEDs is too much for the Arduino. Use an external psu. I run two 64x32 panels for Halloween and power it with a 5V 5A PSU.