-
LED crazy
Hi all I'm new here to the forum.
I download the demo ver. of the picbasic pro
and was able to make some leds blink with a
16f84a chip.
Is there a way to make a led dim to low and then
dim up to high?
I tryed to make some wild program to do this
but it is full of errors.
I know basic some what and have some know how
in programing.
A little.
For some reson it dont like my veriables.
Can anyone show me the picbasic code to do this?
Thanks for any help!
-
Hi,
There's lots of ways to acomplish what you want, most of them involve some kind of PWM generating. Generating that PWM can be done with PBP's PWM command for a software-only-aproach or by the PICs hardware CCP module.
If dimming that LED up and down is all you want then something quick and dirty like this might do the trick:
Code:
TRISB.7=0 'Set PortB.7 to output, connect LED here.
DutyCycle VAR byte
Start:
For DutyCycle = 0 to 255
PWM PortB.7, DutyCycle, 10
Next
For DutyCycle = 255 to 0 Step -1
PWM PortB.7, DutyCycle, 10
Next
Goto Start
That's one way...also have a look at the HPWM command and search this forum for Darrel Taylors software PWM routines.
/Henrik.
-
led crazy
Thanks HenrikOlsson
Thats what I was looking for.
Very nice of you to help me.
Now I can take this code you made
and mess with it.
You know like add more leds and mess with
the fade time.
Thanks again!