twinkle little star

Need some guidance please...
Working with my girl on a school project and we want to simulate a star in the sky. Trying to; run a LED @ 50% the whole time and to be able to give it a quick flash @100% as needed for the effect.


Senior Member
Something to try is PWMOUT which can be varied for greater effect and then also have another pin to the LED through a diode where you turn that pin on and off with PULSOUT - with another resistor in series as well [i.e. 270 ohms in series with PWMOUT pin and say 150 ohms and a diode in series with the PULSOUT pin both to the same LED + pin with its - pin to V-]. RANDOM can be used for irregular twinkle times to trigger the PULSOUT flash.


Senior Member
@ premelec ....thats a good idea ... would a schottky diode work with that speed or would you use a normal one?
I might give it a try


Senior Member
At the PWMOUT speeds likely diode type doesn't matter much - mainly the diode voltage drop is your consideration - schottky diode has lowest voltage drop... I was assuming the pin drive current was all that was needed - if you have need for bigger current output than 20ma then use a LL MOSFET or two...


Technical Support
Staff member
You probably don't need PWMOUT. You can hardwire the LED fr the background brightness then just PULSOUT a pin to go low to create a brighter flash -

-.- +V
 |              ___
 `---|>|---.---|___|--------( PICAXE
           |    ___
     LED   `---|___|---.
                      _|_ 0V
Keep the PICAXE pin as an input normally, PULSOUT then execute another INPUT command.


Senior Member
This program will flash the LED at a random time between 100 and 755 mS delay between flashes
The minimum brightness of the led can be set by experiment and the duration of the flash can be set by the
second pause.

I tested the program with a standard LED.

' 08m2 program for star simulation
setfreq M4
pwmout c.2,100,0
		random w0
		w1 = w0/100 + 100  'Range between  100 to 855 mS 
		pwmduty c.2, 20  'this value is set for min dim level.  Found be experiment.
		pause w1        ' random on time of minimum level 
		pwmduty c.2,400  ' led max ON
		pause 20  'value in mS 100% LED on time.