Trinket MO regulating voltage out put

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Johnnyriotatx
 
Posts: 2
Joined: Thu Oct 07, 2021 3:40 pm

Trinket MO regulating voltage out put

Post by Johnnyriotatx »

Long time listener first-time poster here.
Im not sure where to start with my search for the correct code to control my Trinket MO, so ill ask here. I need to make a simple circuit that will take a button click and reduce the output voltage by a % for each click. The consumer of this voltage would be 5 Small LEDS and my goal is to reduce their intensity per click until they are off. Once off I need to have a single click turn on the light to 100%.
Im not really that familiar with Circuit python outside of modifying a few snippets of code, so I'm not sure this is something I can write from scratch. Where would be a good place to start with this? Any help or pointing in the right direction would be awesome. I've attached a diagram of what I need to build.
Attachments
Screen Shot 2021-10-07 at 2.35.59 PM.png
Screen Shot 2021-10-07 at 2.35.59 PM.png (342.11 KiB) Viewed 352 times

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinket MO regulating voltage out put

Post by dastels »

You should use PWM to control the power to the LEDs rather than voltage. LEDs are diodes, and don't vary brightness linearly with voltage. Using a PWM signal lets to control brightness by rapidly turning the LEDs full off and fully on. The higher the percentage of time they are on, the brighter they look. See https://learn.adafruit.com/circuitpytho ... python-pwm.

Dave

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinket MO regulating voltage out put

Post by dastels »

Also, if you are going to have 5 LEDs in parallel, you'll need to do something more than just connect it to a Trinket pin. 5 LEDs will need 100mA when on., while the absolute maximum for each Trinket pin is 10mA (although not exceeding 7mA is recommended). Use the Trinket pin to control a transistor to switch power to the LEDs. See https://learn.adafruit.com/transistors-101, https://learn.adafruit.com/all-about-leds, and https://learn.adafruit.com/adafruit-ard ... 3-rgb-leds for more information.

Dave

User avatar
Johnnyriotatx
 
Posts: 2
Joined: Thu Oct 07, 2021 3:40 pm

Re: Trinket MO regulating voltage out put

Post by Johnnyriotatx »

Super helpful thank you,! Is there another small board that you could recommend that may work better? I'm not tied to the trinket just happens to be one of the boards I have. In the final version of this, the LEDs will be on a PCB. Will that affect anything?

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinket MO regulating voltage out put

Post by dastels »

All microcontroller boards/chips will be much the same in this regard. If you need more than a few mA, you need to do more than just the MCU pin. For LEDs, simple transistors suffice. Being on a PCB won't have any effect to the circuit.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”