Hello to all,
I want to make the following thing:
I have a 16f84 and I want that when pulsing in RB0 on a led in RB1 and if I press the same one again off the led.
Somebody can help me.
Greetings
Hello to all,
I want to make the following thing:
I have a 16f84 and I want that when pulsing in RB0 on a led in RB1 and if I press the same one again off the led.
Somebody can help me.
Greetings
I am very tired and drunk and am just writing this without trying it but here it goes.
flag var bit
flag = 0
start:
If portb.0 = 1 and flag=0 then
portb.1 = 1
flag = 1
pause 1000
end if
if portb.0 = 1 and flag=1 then
portb.1=0
flag = 0
pause 1000
endif
goto start
The flag is a way for the micro to keep track of which state is currently on. The pause allows the user to remove there finger from the button so the LED is constantly flashing. This may neet to be adjusted. This will be 1000 ms.
flag var bit
flag = 0
start:
If portb.0 = 1 and flag=0 then
portb.1 = 1
flag = 1
pause 1000
endif
if portb.0 = 1 and flag=1 then
portb.1=0
flag = 0
pause 1000
endif
goto start
The endif should not have had a space in it. I also didn't meand the LED would flash. The pause is so it won't flash.
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=390&d=1122866228">from what i understand...
Code:IF PORTB.0=0 then TOGGLE PORTB.1 WHILE PORTB.0=0 : Wend : pause 50 ENDIF
Last edited by mister_e; - 1st July 2006 at 09:41.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I didn't even realize that toggle command was in there. I that case I could change my code to:
input portb.0
start:
If portb.0 = 1 then
toggle portb.1
pause 1000
endif
goto start
I still think you need the pause of at least a second. Otherwise the light will pulse when you are holding the button. You need a delay to allow the user to remove there finger.
both will work, mine just sit there until the button is release, then it allow a 50mSec of debouncing delay.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hello friends,
What I want is this:
If RB0 is 0 RB1 is ON and IF RB0 is 1 RB0 is off , every time that presses the led it should change state.
Thank you
Originally Posted by mister_e
in a loop it have to work.Code:PORTB.1=~PORTB.0
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hello mister and,
Can give me an example about this please. PORTB.1=~PORTB.0
Thank you
Leonard
Originally Posted by mister_e
Bookmarks