YOUR Logic is wrong ...
Alain
YOUR Logic is wrong ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
You ain't going to make this easy for me are you !
A hint in the right direction would help !!
OK following your advice I RTFM and it states
So I applied the same logic to the codeIf (B0 = 10) And (B1 = 20) Then loop
ie if swset1 and swset2 both =1 then jump to occ, occ simply turns on LED3If swset1=1 and swset2=1 then occ
occ:
high led3
This didn't work. It seems that its ignoring the "and" part of the statement
I mean this ain't exactly rocket (or should I say space shuttle) science
Perhaps because you ignored the parentheses?Originally Posted by malc-c
Hi, Malc
try this:
CMCON=7
TRISB=%00000011 'set RB0 & 1 as input and the rest output
SW1 var PORTB.0 'switch input pin 6 (RB0)
SW2 var PORTB.1 'switch input pin 7 (RB1)
LED1 var PORTB.4 'LED1 on pin 10 (RB4)
LED2 var PORTB.5 'LED1 on pin 11 (RB5)
Swset1 var bit
Swset2 var bit
Swset5 var bit
low led1
low led2
Swset1=0
Swset2=0
swset5=0 'Var swset is set low
Main:
if SW1=0 then
'If switch is LOW (Grounded) then
IF swset5 =1 THEN
swset1 = 0
swset2 = 0
swset5 = 0
loop: IF sw1=0 then loop 'wait for button release ... Yessss !!!
GOTO jump
ENDIF
Toggle Swset1 'change swset1 from 0 to 1
pause 500 'debounce delay
endif
if SW2=0 then 'If switch is LOW (Grounded) then
Toggle Swset2 'change swset2 from 0 to 1
pause 500 'debounce delay
endif
Jump:
If Swset1=1 then 'if swset1 is 1
high led1 'then turn on RB4 (and hence the LED)
else
low led1 'else, LED is off
endif
If Swset2=1 then 'if swset2 is 1
high led2 'then turn on RB5 (and hence the LED)
else
low led2 'else, LED is off
endif
If swset1=1 and swset2=1 then
toggle swset5
endif
Goto Main
End
And now try to understand WHY !!!
Alain
Last edited by Acetronics2; - 15th May 2006 at 15:36.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Thanks, and yes it compiles OK and in tests works as required approx 70% (ie 7 out of 10) of the time. On three attepts LED2 remained lit, but its a lot better than my 0% success rateOriginally Posted by Acetronics
![]()
OK I'll have a go...
And now try to understand WHY !!!
Sets up the PIC and the varibles
CMCON=7
TRISB=%00000011 'set RB0 & 1 as input and the rest output
SW1 var PORTB.0 'switch input pin 6 (RB0)
SW2 var PORTB.1 'switch input pin 7 (RB1)
LED1 var PORTB.4 'LED1 on pin 10 (RB4)
LED2 var PORTB.5 'LED1 on pin 11 (RB5)
Swset1 var bit
Swset2 var bit
Swset5 var bit
low led1
low led2
Swset1=0
Swset2=0
swset5=0 'Var swset is set low
If pin is grounded then check to see if varible bit swset5 is set high, and if so then swset 1,2 and 3 are all set low
Main:
if SW1=0 then
'If switch is LOW (Grounded) then
IF swset5 =1 THEN
swset1 = 0
swset2 = 0
swset5 = 0
constantly loop round checking pin sw1 to see if groundedloop: IF sw1=0 then loop 'wait for button release ... Yessss !!!
and if so, goto the section of the code labled jump....
GOTO jump
ENDIF
if the varibles swset 1 is high then turn on its corresponding LED, if low then turn off the LED, same thing for swset2
Jump:
If Swset1=1 then 'if swset1 is 1
high led1 'then turn on RB4 (and hence the LED)
else
low led1 'else, LED is off
endif
If Swset2=1 then 'if swset2 is 1
high led2 'then turn on RB5 (and hence the LED)
else
low led2 'else, LED is off
endif
If swset1 and swset2 are both high then change the state of swset5 to high, which iwhen checked by the line aboveIf swset1=1 and swset2=1 then
toggle swset5
endif
Goto Main
IF swset5 =1 THEN
swset1 = 0
swset2 = 0
swset5 = 0
resets swset1, swset2 and swset5 back to 0, and conversly all LEDs are turned off
Checks sw2 and changes the state of swset2 (and thus LED2)
Toggle Swset1 'change swset1 from 0 to 1
pause 500 'debounce delay
endif
if SW2=0 then 'If switch is LOW (Grounded) then
Toggle Swset2 'change swset2 from 0 to 1
pause 500 'debounce delay
endif
End
Well how did I do ??
Guys you crack me up... here am I trying to get technical and you guys are trying to put me mind off the subject by posting pictures of pussy on a public forum![]()
![]()
Bookmarks