Skip to content
This repository has been archived by the owner on Dec 8, 2019. It is now read-only.

LED brightness #34

Open
JonasArnold opened this issue Aug 17, 2017 · 0 comments
Open

LED brightness #34

JonasArnold opened this issue Aug 17, 2017 · 0 comments

Comments

@JonasArnold
Copy link

The maximum analogWrite on the ESP8266 value is not 255 (as in the code) but 1023. Because of that the LED is much less bright than it could theoretically be.
Adapting the map-command results in the following problems:

  • larger datatype for the real"Color" variables needed (int would be fitting)
  • the timing concerning fadetimes is different (positive about it: the LED can be dimmed much more smoothly due to more steps)

I tried adapting the code but I failed at the transition-part.
The following piece of code (in the callback-function) should work fine:

realBrightness = map(brightness, 0, 255, 0, 1023);
realRed = int(map(red, 0, 255, 0, realBrightness));
realGreen = int(map(green, 0, 255, 0, realBrightness));
realBlue = int(map(blue, 0, 255, 0, realBrightness));

realBrightness, realRed, realGreen, realBlue must now be integer-variables.

Now theoretically only the problem with the fade time is left: I tried increasing the number of steps from 1020 to 4090 or so... but then I failed making the whole process faster (more steps @ same time -> the Count-Loop must be processed more oftenly -> the whole loop must be faster)...

By the way you also need to adapt the following if-condition:
// Defensive driving: make sure val stays in the range 0-255
if (val > 1023) {
val = 1023;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant