Connect with us

How to make the brightness of the LED change?

Discussion in 'LEDs and Optoelectronics' started by bancroft, Jul 27, 2021.

Scroll to continue with content
  1. bancroft

    bancroft

    76
    2
    Apr 23, 2021
    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.
     
  2. Martaine2005

    Martaine2005

    4,084
    1,116
    May 12, 2015
    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
     
  3. bancroft

    bancroft

    76
    2
    Apr 23, 2021
    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?
     
  4. Martaine2005

    Martaine2005

    4,084
    1,116
    May 12, 2015
    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
     
  5. bancroft

    bancroft

    76
    2
    Apr 23, 2021
    Yes I will, thank you very much!
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    12,447
    2,981
    Nov 17, 2011
    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.
     
    Martaine2005 likes this.
  7. bancroft

    bancroft

    76
    2
    Apr 23, 2021
    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!
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-