Dimming LED's with no PWM pins from uC

Thread Starter

artmaster547

Joined Jan 6, 2016
409
Hi All
I am looking for an IC/Circuit schematic, that enables control of two LED's allowing them to be dim in and out (i.e. create a "breathing effect"), but I do not have any spare PWM pins on the uC but it is possible to use GPIO pins, I2C pins or SPI pins can anybody recommend what I could use?
Any recommendations would be greatly appreciated.

Kind Regards

Art
 

spinnaker

Joined Oct 29, 2009
7,830
You can simply do bit bang PWM.

https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

Just one of many, many examples. You need to provide more detail for more specific help. The microchip used for one.

This is probably one of the most simple projects you can do. It is one step up from the "Hello World" turn on an LED project that you usually cover when learning microcontrollers.

And this should be in the embedded forum.
 

Thread Starter

artmaster547

Joined Jan 6, 2016
409
You can simply do bit bang PWM.

https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

Just one of many, many examples. You need to provide more detail for more specific help. The microchip used for one.

This is probably one of the most simple projects you can do. It is one step up from the "Hello World" turn on an LED project that you usually cover when learning microcontrollers.

And this should be in the embedded forum.
Hi the micro controller I am using is an LPC11c12, I know it's really simple with Arduino because a lot of libraries have already been written but I have not really tried to do anything from scratch so any assistance would be appreciated.
 

spinnaker

Joined Oct 29, 2009
7,830
Hi the micro controller I am using is an LPC11c12, I know it's really simple with Arduino because a lot of libraries have already been written but I have not really tried to do anything from scratch so any assistance would be appreciated.

This isn't that difficult of a project. You don't need a library aside from a delay. And if that does not exist then just write one.

Why don't you first try reading the article and see how it is going to apply to your chip? This is probably one of the most basic of projects.



Likely one one is gong to write code for you, especially for such an odd mcu.
 

Thread Starter

artmaster547

Joined Jan 6, 2016
409
This isn't that difficult of a project. You don't need a library aside from a delay. And if that does not exist then just write one.

Why don't you first try reading the article and see how it is going to apply to your chip? This is probably one of the most basic of projects.



Likely one one is gong to write code for you, especially for such an odd mcu.
could you write the pseudo code by any chance the main thing is figuring out the timings for on and off I understand how to toggle the LED it's just figuring out the timings that seems to be the issue and the period of when it is on to get it to dim, tbh I understand how to add in delays and so on
 

spinnaker

Joined Oct 29, 2009
7,830
Start:

Turn LED On
Delay
Turn LED off
Delay

Add to Delay
If delay limit is reached reset delay

Goto to start

You will just need to experiment with the length of delay and how much it increases to see what looks good.
 

Thread Starter

artmaster547

Joined Jan 6, 2016
409
Start:

Turn LED On
Delay
Turn LED off
Delay

Add to Delay
If delay limit is reached reset delay

Goto to start

You will just need to experiment with the length of delay and how much it increases to see what looks good.
Ok great thank you I see you just increment the delay in a loop that makes sense

Thanks

Art
 

spinnaker

Joined Oct 29, 2009
7,830
Ok great thank you I see you just increment the delay in a loop that makes sense

Thanks

Art
And you might want to decrease it too. Example increase in steps till delay reaches a certain high limit then decrease in steps till it is decreased to a certain low limit.

You could also have a counter for how often it is increased or decreased.

Turn LED On
Delay
Turn LED off
Delay

Add 1 to StepCount

If StepCount > 10
StepCount = 0
Add to Delay
If delay limit is reached reset delay
Endif

Goto to start


This will slow the rate of growth.
 

Thread Starter

artmaster547

Joined Jan 6, 2016
409
And you might want to decrease it too. Example increase in steps till delay reaches a certain high limit then decrease in steps till it is decreased to a certain low limit.

You could also have a counter for how often it is increased or decreased.

Turn LED On
Delay
Turn LED off
Delay

Add 1 to StepCount

If StepCount > 10
StepCount = 0
Add to Delay
If delay limit is reached reset delay
Endif

Goto to start


This will slow the rate of growth.
Great thank you appreciate the assistance I will play around with this thanks Art
 
Top