Maker Pro
Maker Pro

How to make the brightness of the LED change?

I have done a preliminary effect of the project, now it is still missing to control the LED brightness change by clicking the number + or number - of the touch screen. When I click on "+" I want the LED brightness to get brighter and brighter as the number increases and conversely decreases. Is this possible to achieve? If so is there a sample code?
By the way, I use Arduino UNO and F5LED.
 
I don't know anything about code for arduino but I do have lots of libraries that have sample and complete codes.
The code you want would be for PWM (pulse width modulation).
I think 'FastLED' has all you want. Check it out in your Arduino library.

Martin
Thank you very much for the suggestion, I installed this library in my Arduino IDE, do you have some sample code? Or which example from this library should I choose to learn?
 
I'll leave this open for the experienced members to answer.
But I will say that some of the code names in the libraries are rather strange and don't always describe it's function.
Adafruit libraries also have lots of examples.
I would suggest broadboarding or connecting your LEDs and try different examples.

Martin
 
I'll leave this open for the experienced members to answer.
But I will say that some of the code names in the libraries are rather strange and don't always describe it's function.
Adafruit libraries also have lots of examples.
I would suggest broadboarding or connecting your LEDs and try different examples.

Martin
Yes I will, thank you very much!
 

Harald Kapp

Moderator
Moderator
The FASTLED library is for adressable RGB LEDs, not suitable for controlling the brightness of a standard LED via PWM.
Here is a simple example for controlling the brightness of an LED using PWM (in the disguise of AnalogWrite()) without any additional library.
Replace the potentiometer and the associated code by your code that evaluates the '+' and '-' softbuttons on your touchscreen.
 
The FASTLED library is for adressable RGB LEDs, not suitable for controlling the brightness of a standard LED via PWM.
Here is a simple example for controlling the brightness of an LED using PWM (in the disguise of AnalogWrite()) without any additional library.
Replace the potentiometer and the associated code by your code that evaluates the '+' and '-' softbuttons on your touchscreen.
Thank you very much, that's a very detailed tutorial! I'll try to modify this code and understand what it means, thank you again!
 
Top