What to buy?

Greetings from a newbie

Have a little project coming up and dont really know what gear to get.
It has to handle two ultrasonic distance sensors and be able to
individually fade in/out 16 leds. Depending on the distance it has
to fade in a specific led.

Is PWM the way to go or what should I look for? :~

regards Matias

edit: found leonardo and micro both with 20 digital pins

PWM is the way to go but 16 PWM LED's could be a problem as Arduino does not have that many hardware PWM pins. SoftPWM may work but I have not tried it myself.
How are you going to mount the LED's? Will you use a PCB/Stripboard/Breadboard. Something like the WS2308 is cheap and can handle 18 dimable LED's with only a couple of extra components (1 resistor & a capacitor)

Pizza_m79:
Greetings from a newbie

Have a little project coming up and dont really know what gear to get.
It has to handle two ultrasonic distance sensors and be able to
individually fade in/out 16 leds. Depending on the distance it has
to fade in a specific led.

16 LEDs with PWM? Sounds like a job for the mighty TLC5940...

I have worked with the softPWM-library, which works nice. Turning on all leds at the same time to show a distance might cause more current to flow as an arduino-chip can handle though.
Besides the WS2803 and TLC5940 mentioned by Fungus and Riva a MAX7219 or MAX7221-chip could also be used to PWM 16 leds.

Simpson_Jr:
Besides the WS2803 and TLC5940 mentioned by Fungus and Riva a MAX7219 or MAX7221-chip could also be used to PWM 16 leds.

Alas the MAX7219/MAX7221 only has 16 levels of dimming and it effects all ports equally at the same time.

Arduino can individually control up to 500 of these (Breadboard-friendly RGB Smart NeoPixel - Pack of 4 : ID 1312 : $7.95 : Adafruit Industries, Unique & fun DIY electronics and kits), with full PWM & RGB, using only one pin.

Good enough?
:slight_smile:

1ChicagoDave:
Arduino can individually control up to 500 of these (Breadboard-friendly RGB Smart NeoPixel - Pack of 4 : ID 1312 : Adafruit Industries, Unique & fun DIY electronics and kits), with full PWM & RGB, using only one pin.

Only 500? I didn't think there was a limit.

fungus:

1ChicagoDave:
Arduino can individually control up to 500 of these (Breadboard-friendly RGB Smart NeoPixel - Pack of 4 : ID 1312 : Adafruit Industries, Unique & fun DIY electronics and kits), with full PWM & RGB, using only one pin.

Only 500? I didn't think there was a limit.

An Arduino can drive up to 500 pixels at 30 FPS (it will run out of RAM after that).

1ChicagoDave:

fungus:

1ChicagoDave:
Arduino can individually control up to 500 of these (Breadboard-friendly RGB Smart NeoPixel - Pack of 4 : ID 1312 : Adafruit Industries, Unique & fun DIY electronics and kits), with full PWM & RGB, using only one pin.

Only 500? I didn't think there was a limit.

An Arduino can drive up to 500 pixels at 30 FPS (it will run out of RAM after that).

What if I don't want 30fps or I'm not storing the color of each pixel in three bytes of RAM?

(Even with three bytes/pixel I think I can get more than 500 in 2048 bytes of RAM).

fungus:

1ChicagoDave:

fungus:

1ChicagoDave:
Arduino can individually control up to 500 of these (Breadboard-friendly RGB Smart NeoPixel - Pack of 4 : ID 1312 : Adafruit Industries, Unique & fun DIY electronics and kits), with full PWM & RGB, using only one pin.

Only 500? I didn't think there was a limit.

An Arduino can drive up to 500 pixels at 30 FPS (it will run out of RAM after that).

What if I don't want 30fps or I'm not storing the color of each pixel in three bytes of RAM?

(Even with three bytes/pixel I think I can get more than 500 in 2048 bytes of RAM).

Ok, try it & let us know how it goes.

Here's link to the library —

What if we imagine that I didn't design the thing, and I'm just quoting what the designers of the strips & writers of the library claim are the limits? (What if the OP has not the necessary coding skills, or desire, to rewrite the library in attempt to increase those limits?
What if I just posted that link to help the OP accomplish their goal, and not to debate theoretical limits of the technology? — Context, context...)

I do know that if I break my code up into just a few extra functions...with only 16 of these LEDS/pixels...it doesn't work correctly. Timing is apparently extremely important & somewhat delicate.

Seriously, if you can improve the library to handle more pixels...go for it! It's open source. I'm sure they'd be grateful!

1ChicagoDave:
What if we imagine that I didn't design the thing, and I'm just quoting what the designers of the strips & writers of the library claim are the limits? (What if the OP has not the necessary coding skills, or desire, to rewrite the library in attempt to increase those limits?

OK, so it's 500 LEDs using the Adafruit Neopixel library.

In theory though, there's no limit to the number of LEDs, eg. if you want them all the same color or you can generate the colors using a formula.

I don't know why you have timing issues. I drive them with Arduino Unos, 8MHz Tiny85s, no problem.