twinkle little star

#1
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.
Dave
 

premelec

Senior Member
#2
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.
 

newplumber

Senior Member
#3
@ 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
 

premelec

Senior Member
#4
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...
 

hippy

Technical Support
Staff member
#5
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 -

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

Bill.b

Senior Member
#6
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.

Code:
' 08m2 program for star simulation
setfreq M4
pwmout c.2,100,0
main:
	do
		random w0
		w1 = w0/100 + 100  'Range between  100 to 855 mS 
		'debug
		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.  
		
	loop

Bill
 
Top