Why Processing Light of Arduino Keeps Dimming

LEDEffects

Below an overview of this article.

All these effects work with NeoPixel and FastLED, and with each effect I made a little demo video.

UPDATE – All effects in one sketch

Bij popular demand, I've written an article how all these effects can be placed in one sketch, allowing you to toggle effects.
Read more about it in this article: Arduino – All LED effects in one Sketch. (updated the link)

Overview

  • 1LEDEffects
  • 2Preparing your Arduino and your LED strip
  • 3Helpful tool: Color Picker
  • 4Make your effects cooler: Diffuse Light (toilet paper magic)
  • 5Required Library - NeoPixel or FastLED ?
    • Basic framework
      • FastLED Framework
      • NeoPixel Framework
  • 6LEDStrip Effect - Fade In and Fade Out: Red, Green and Blue
  • 7LEDStrip Effect - Fade In and Fade Out Your own Color(s)
  • 8LEDStrip Effect - Strobe
  • 9LEDStrip Effect - Blinking Halloween Eyes
  • 10LEDStrip Effect - Cylon
  • 11LEDStrip Effect - The new KITT
  • 12LEDStrip Effect - Twinkle
  • 13LEDStrip Effect - Random Color Twinkle
  • 14LEDStrip Effect - Sparkle
  • 15LEDStrip Effect - Snow Sparkle
  • 16LEDStrip Effect - Running Lights
  • 17LEDStrip Effect - Color Wipe
  • 18LEDStrip Effect - Rainbow Cycle
  • 19LEDStrip Effect - Theatre Chase
  • 20LEDStrip Effect - Theatre Chase Rainbow
  • 21LEDStrip Effect - Fire
  • 22LEDStrip Effect - Bouncing Balls
  • 23LEDStrip Effect - Multi Color Bouncing Balls
  • 24LEDStrip Effect - Meteor Rain

  Ad Blocking Detected

Please consider disabling your ad blocker for our website.
We rely on these ads to be able to run our website.
You can of course support us in other ways (see Support Us on the left).

Preparing your Arduino and your LED strip

Please keep in mind that these effects are here for you to play with and hopefully invite you to create your own cool effects …

For your convenience, you can download all sources here as well:

Download - LEDEeffects Sources

Filename: LEDEeffects-Sources.zip
Platform: Undefined
Version: 1.0
File size: 34.5 kB
Date: 2015-11-08
 Download Now Send me a cup of Coffee

These examples rely on the following setup (as described in the Controlling a WS2812 LED with an Arduino article).
Please read carefully.

Arduino IDE and Library versions

For this article I have used the Arduino IDE 1.6.6, which (after you installed either FastLED or NeoPixel) will show a message to update either of these (and possibly others) libraries. Please do so.

Arduino Connected to PC

The following I use for when the Arduino is connected to my PC :

Arduino & WS2812 - USB and External Power

Arduino & WS2812 – USB and External Power

Arduino Standalone

After you've uploaded your variation of effects into the Arduino, and you'd like it to run standalone, then this setup is what you need. Without a connection to your computer, the Arduino will need +5V from the external power supply.

This is for stand-alone ONLY so when the Arduino is NOT connect to a PC!

Arduino & WS2812 - Only running on external power supply

Arduino & WS2812 – Only running on external power supply

This tool might be helpful when picking colors:
LED colors are build up out of 3 numbers:red, green and blue (RGB).
Each number is a byte so it each has a range of 256 values (Decimal: 0 … 255, Hexadecimal: 00 … FF).

Now the human brain (usually) doesn't work with RGB numbers, so I've added this little tool to pick colors.
You can select the color and it should give you the hexadecimal value of the selected color.
Please note that the LED colors might be slightly off – after all they are not calibrated.


Color picker:

Usage:
Click the input box and a popup will show a color picker. Choose your color, and the hexadecimal value will appear.
To use this in your Arduino Sketch:

The first 2 characters represent RED ,
the second set of two characters is for GREEN and
the last 2 characters represent BLUE .

Add '0x' in front of each of these hex values when using them ('0x' designates a hexadecimal value).

Example:
Thispurple isB700 FE.
The hexadecimal values: red is B7 , green is 00 and blue is FE .

As the Arduino can work straight away with hexadecimal number, you will need to type "0x" in front of it – so it can see the difference between regular decimal number and these hexadecimal numbers.
So for example a NeoPixel strip.Color() call would look something like this:

strip.Color ( 0xB7 , 0x00 , 0xFE ) ;

  Ad Blocking Detected

Please consider disabling your ad blocker for our website.
We rely on these ads to be able to run our website.
You can of course support us in other ways (see Support Us on the left).

Make your effects cooler: Diffuse Light (toilet paper magic)

I love playing with these LED strips, but sometimes they feel a little too … I don't know how to say it.
With some effects you'd prefer to not see the individual LEDs light up.

To remedy that without too much effort, you can diffuse the light – make it more fuzzy.

There are different techniques for that, anywhere from using ping-pong balls (which works great for one or two LEDs), frosted glass (tube light!) or plastic tubes, cloth sheets etc.

I had none of these available – I used to have ping ping balls but my dog decided it to be awesome for chasing and chewing. So I'm out of those.

To my surprise, regular toilet paper (yes!) actually does a pretty good job with the diffusing as well. Naturally, I had only "fancy" toilet paper with a print on it, and neutral toilet paper would have looked even better, but you get the idea when you se these two examples.

Just make sure to keep the toilet paper roughly an inch (2 to 3 centimeter) above the LEDs – don't let the LEDs touch the toilet paper.

Note: Both examples look better when held vertical, but without much assistance in my house, I had to do it horizontally.

The Fire Effect is my favorite and shows best in a darker environment, but look at what the toilet paper is doing … I love it!

The Red, White and Blue bouncing balls look a lot more interesting when diffused as well.

Required Library – NeoPixel or FastLED ?

Since both are pretty good, but are not used in the same way – ie. they are not drop-in replacements for each other. That's why I decided to create a few "generic" functions so that the "effect" function here can be generic as well, so these functions work with either of these 2 libraries.

Either library can be used!

First make sure either NeoPixel or FastLED is installed. To install one (or both) of these desired library, I refer you to the article "Arduino – Controlling a WS2812 LED strand with NeoPixel or FastLED".

Note : FastLED seems slightly faster. In the tests I've run I would estimate that FastLED is about 15% faster than NeoPixel. You will notice this with large amounts of LEDs (as I experienced with 300+ LEDs). On the other hand, NeoPixel seems to take less memory on your Arduino. Also note that the functions in FastLED are far superior to NeoPixel.

Now I wrote tiny wrappers around some of the basic functions of NeoPixel and FastLED – and I'm sure there is room for improvement. Suggestions are welcome.

Basic framework

For each of the LEDStrip effects, we will use a basic framework of code which we reuse in each of the effects.
It is important that you pay attention to these since the basic settings for your strip is being done there.

Now in this framework I've also defined 3 generic functions.
These functions will automatically grab the code needed for the library you're using (when compiling).

showStrip( );

This function simply applies the recent changes to pixel colors and makes them visible.
It calls strip.show (NeoPixel) or FastLED.show (FastLED).

setPixel(Pixel, red, green, blue);

With this function we set the color of an individual pixel (LED).
You will need to pass the pixel number (start counting at zero) and the RGB values.
For NeoPixel it will call setPixelColor, and for FastLED it will assign values to the leds array.

setAll( red, green, blue);

This function sets the entire strip to a give color. You can use it to set the entire strip to a given color or for example with setAll(0,0,0) to black (off).

The code we present, with each of the effects, is simple replacing this part of the code in the framework code:

            

1
2
3
4
5
6
7

// *** REPLACE FROM HERE ***
void loop( ) {
// ---> here we call the effect function <---
}

// ---> here we define the effect function <---
// *** REPLACE TO HERE ***

So in our effects code examples you will only see theloop() section and the effect function.
Settings and the 3 wrapper functions will not be displayed, but are most certainly needed!

FastLED Framework

This is the basic code for use with theFastLED library.

Here we include the needed library (line 1), define the number of LEDs (line 2), define the Arduino pin used (line 4), and define some strip specific settings (line 8) like color order (RGB, GRB etc.).

            

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

#include "FastLED.h"
#define NUM_LEDS 60
CRGB leds[NUM_LEDS] ;
#define PIN 6

void setup( )
{
FastLED.addLeds <WS2811, PIN, GRB> (leds, NUM_LEDS).setCorrection ( TypicalLEDStrip ) ;
}

// *** REPLACE FROM HERE ***
void loop( ) {
// ---> here we call the effect function <---
}

// ---> here we define the effect function <---
// *** REPLACE TO HERE ***

void showStrip( ) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show ( ) ;

0 Response to "Why Processing Light of Arduino Keeps Dimming"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel