I did something similar a couple of years ago and just dug up the code. I can't remember if it worked well, but I kept the code, so maybe... I will have to wire one up to test and also try your code as well. Fun stuff!!!
Just found another one from the way back section of my server. If I remember right, I had a big led that wasn't responding to the pwm like a normal led, so a kind sole in the forum had a different (slower) pwm library that I may have used here. Not exactly sure right now. Have to hook things back up and try them out... I also think I found this routine somewhere and modified it for GCB.
#chip 12f1840,32#DEFINE LED PORTA.2DIRPORTA.2outDirPORTA.1InrandomizeReadAD(AN1)#defineflicker_low_min120#defineflicker_low_max160#defineflicker_high_min230#defineflicker_high_max255#defineflicker_hold_min40#defineflicker_hold_max80#defineflicker_pause_min20#defineflicker_pause_max155#defineflicker_speed_min5#defineflicker_speed_max200flicker_random_low_start=0flicker_random_low_end=0flicker_random_high=0flicker_random_speed_start=0flicker_random_speed_end=0doforpp=1to10'random time for low flicker_random_low_start = rolldice(flicker_low_min, flicker_low_max) flicker_random_low_end = rolldice(flicker_low_min, flicker_low_max) 'randomtimeforhighflicker_random_high=rolldice(flicker_high_min,flicker_high_max)'random time for speed flicker_random_speed_start = rolldice(flicker_speed_min, flicker_speed_max) flicker_random_speed_end = rolldice(flicker_speed_min, flicker_speed_max) 'low->highfornn=flicker_random_low_starttoflicker_random_highhpwm1,16,nnwaitflicker_random_speed_start10usnextnn'hold wait rolldice(flicker_hold_min, flicker_hold_max) ms 'high->lowfornn=flicker_random_hightoflicker_random_low_endstep-1hpwm1,16,nnwaitflicker_random_speed_end10usnextnnwaitrolldice(flicker_pause_min,flicker_pause_max)msnextpploopfunctionrolldice(minval,maxval)rn=Randomaa=maxval-minval+1bb=rnmodaarolldice=minval+bbend function
Last edit: Moto Geek 2017-12-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for my english.
This is the adaptation of a program I had written in another language to generate the flame of 8 candles with independent flicker.
The delay in milliseconds should be chosen based on the desired effect.
With this circuit I turn on the candles consisting of incandescent microlamps but I think that with the LEDs it goes well.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is that time of year!
My LED candle simulator! Anyone else got a better solution?
https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/tree/master/LED%20Solutions/LED%20-%20Candle%20Simulator
Enjoy
I did something similar a couple of years ago and just dug up the code. I can't remember if it worked well, but I kept the code, so maybe... I will have to wire one up to test and also try your code as well. Fun stuff!!!
Like it - works very nicely! Uses CCP1/PWM clever but does need the CCP module.
Just found another one from the way back section of my server. If I remember right, I had a big led that wasn't responding to the pwm like a normal led, so a kind sole in the forum had a different (slower) pwm library that I may have used here. Not exactly sure right now. Have to hook things back up and try them out... I also think I found this routine somewhere and modified it for GCB.
Last edit: Moto Geek 2017-12-21
NICE! Love the dice function! This has more of random flicker!
Also, looks very nice on the scope!
Santa is coming!
Last edit: Anobium 2017-12-19
I use the rolldice function quite a bit for led fun and other things.
Lotto winning tickets!
So far, just lotto tickets. No winners yet. But if it happens, I will definetly give GCB ALL the credit.
Sorry for my english.
This is the adaptation of a program I had written in another language to generate the flame of 8 candles with independent flicker.
The delay in milliseconds should be chosen based on the desired effect.
With this circuit I turn on the candles consisting of incandescent microlamps but I think that with the LEDs it goes well.
@jackjames
Crazy LEDs!! Look pretty - I got four LEDs operating on a PicKit2 Low Pin Count Board.
:-)