coding for button by using PIC18F4620
Hi everyone..
I'm new in this forum and I hope u guys can help me to solve my problem. I'm try to do a coding for button by using PICF4620 but there is an error.I also not sure whether my program is right or not because this is the first time i'm using Pbasic.
Here the program:
define osc 25
define INIT_ADCON2=0
define INIT_TRISA.2=0
DEFINE INIT_ADCON0=1
DEFINE INIT_TRISB.0=1
DEFINE INIT_ADCON1=1
DEFINE INIT_TRISB.1=1
LED VAR porta.2
BUTTON0 VAR portb.0
BUTTON1 var portb.1
main:
high BUTTON0=1
high LED ;led is ON
pause 600
low LED ;led is OFF
pause 600
high BUTTON1=1
high LED ;led is ON
pause 600
low LED ;led is OFF
pause 600
goto main
Re: Button/switch debouncing
Quote:
Originally Posted by
Melanie
Run with whatever turns you on (or in this case debounces your thing - which may very well need debouncing if you're running with it!!!)...
In programming, there is no single correct way of doing anything - there's a zillion different ways of doing everything. Some more efficient, some less so, some you're comfortable with and work for you, so you stick with them...
You don't HAVE to use any of PICBasics commands... ADCIN, HSERIN, HSEROUT, HPWM, BUTTON are just a few that immediately spring to mind. If you know how to do basic Port I/O and know how to access the PICs internal Registers (if you don't then it's time you did), then there's no reason why you can't and shouldn't do so if you're that way inclined.
thx for ur advice it is the best i've got
John