Page 1 of 1

Controlling with a pot the speed of flash patterns

Posted: Sun Feb 28, 2016 12:45 pm
by Frank607
I have a simple PIC12F629 and programmed in Flowcode seven LED flash patterns. With a button you activate the next pattern.

Now I want to use a potentiometer to adjust the flash speed (delays) of the flash patterns. I can imagine that this is not so easy to do because my flash pattern have a standard delay (50ms) in the flowchart.

Somewhere in this forum I found a year ago a flowchart what seems to do this, but I can’t find it anymore.

Anyone who can help me?

Re: Controlling with a pot the speed of flash patterns

Posted: Sun Feb 28, 2016 1:46 pm
by medelec35
Hi Frank,
This thread may help

Martin

Re: Controlling with a pot the speed of flash patterns

Posted: Sat Mar 05, 2016 3:58 pm
by Frank607
Hi Martin,

Thanks for the link to the topic. I have got my flowchart working with a potentiometer according
to your post.

But one thing I don’t understand very well and that is the calculation:

Code: Select all

Note the calculation
CODE: SELECT ALL
Delay = Delay * 16 / 10 + 100
The value is now 100ms to 500ms. How can I have 50ms >450ms ?

Re: Controlling with a pot the speed of flash patterns

Posted: Sat Mar 05, 2016 9:51 pm
by medelec35
Hi Frank,
Frank607 wrote:The value is now 100ms to 500ms.
That's because of:
medelec35 wrote: Note the calculation

Code: Select all

Delay = Delay * 16 / 10 + 100 
use within the flowchart I posted just takes the digital value derived by ADC (0 to 255) and converts it in to a value suitable for a milliseconds delay (about 100 to just over 500)
Frank607 wrote:How can I have 50ms >450ms ?
You can try:

Code: Select all

Delay = Delay * 39 / 25 + 50
It should be very near is using ReadAsByte.
Probably 50 to 447ms?
Is that accurate enough?