crazylegsmurphy
New Member
Hey Everyone,
I got my PICKit 2 Starter Kit today and I have been trying things out with some success. I have started reading the manuals, online forums, etc. and I'm kind of getting confused.
The sample code that comes with the programmer to blink an LED is:
Everything works great with that, and I am starting to understand the basics of what is going on...but what confuses me is why when I try to use code off the internet it gives me compiling errors?
hmm, I suppose that isn't a great way to describe the problem. What I mean is, how can I work with this code to do things like make it blink faster, slower, random?
Is there something I can do to add a fade? Or can I have it blink to a "beat"?
How do I get it to control the other LED's?
Sorry if that's a loaded question, but any help would be great. I'm in the process of reading tutorials, but because the chips they're using aren't what I am using, the whole thing falls apart when I try to compile things because if I can't move on with the tutorials, then I'm hooped.
Thanks,
Jeff
I got my PICKit 2 Starter Kit today and I have been trying things out with some success. I have started reading the manuals, online forums, etc. and I'm kind of getting confused.
The sample code that comes with the programmer to blink an LED is:
Code:
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
cblock 0x20
Delay1 ; Define two file registers for the
Delay2 ; delay loop
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin B.0 an output
bcf STATUS,RP0 ; back to Register Page 0
MainLoop:
bsf PORTC,0 ; turn on LED C0
OndelayLoop:
decfsz Delay1,f ; Waste time.
goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
; call it a two-tenths of a second.
bcf PORTC,0 ; Turn off LED C0
OffDelayLoop:
decfsz Delay1,f ; same delay as above
goto OffDelayLoop
decfsz Delay2,f
goto OffDelayLoop
goto MainLoop ; Do it again...
end
Everything works great with that, and I am starting to understand the basics of what is going on...but what confuses me is why when I try to use code off the internet it gives me compiling errors?
hmm, I suppose that isn't a great way to describe the problem. What I mean is, how can I work with this code to do things like make it blink faster, slower, random?
Is there something I can do to add a fade? Or can I have it blink to a "beat"?
How do I get it to control the other LED's?
Sorry if that's a loaded question, but any help would be great. I'm in the process of reading tutorials, but because the chips they're using aren't what I am using, the whole thing falls apart when I try to compile things because if I can't move on with the tutorials, then I'm hooped.
Thanks,
Jeff
Last edited: