PDA

View Full Version : led blink help needed



asifiqbal
- 19th March 2014, 14:26
hello
I am beginer and practicing small codes so here is a code and i need help about it
--------------------------------
define osc 4
Trisb =%01111111
do
high portb.7
pause 300
low portb.7
pause 300
loop until portb.2 = 0
---------------------------
when i run this code led on start blinking but when i press button and make portb.2 low then operation of led should stop but it doesent stop ,it keep blinking whether there is 1 or 0 at portb.0
what is wrong this code and how to correct it please guide me thanks

Heckler
- 19th March 2014, 16:10
Which PIC are you using??

make sure that you have analog inputs turned off.

Most PIC's defalult to analog inputs turned on.

Check the ANSEL register (or what ever the analog select register is for the PIC you are using)

the "HIGH" and "LOW" command can mask this problem as it somehow disables the analog for that pin during that command (or something like that)
anyway as I said, most PIC's default to analog inputs enabled.
You need to turn off the analogs if you are just trying to blink an LED.

Do you have the datasheet for your PIC?