A simple IF Statement!!!!
For whatever reason, I have to humbly ask if this is right:
SW1 var porta.0
LED var portb.0
check:
IF SW1 = 1 then LED = 1
goto check
end
It compliles with no errors. Seems pretty straight forward but in anycase, its not working. Porta.0 is getting a 5v sig from SW1 but the LED won't lite.
PBP, PBPDemo, Microcode studio, MPLab, PicPro, and any other IDE I could find.
Thank you,
Mike Slaney
Just wondering IF...
Mister E?....A few questions 'bout your code.
Quote:
Originally posted by mister_e
I always prefer to use SELECT CASE. The easy way to get multiple conditions is to refer to the PORT.
By example
Code:
SW1 VAR PORTB.0
SW2 VAR PORTB.1
SW2 VAR PORTB.2
MaskSwitch=byte
MaskSwitch=PORTB & $07
SELECT CASE MaskSwitch
CASE 1 '%00000001 or SW1
Goto Procedure_SW1
CASE 2 '%00000010 or SW2
Goto Procedure_SW2
CASE 4 '%00000100 or SW3
Goto Procedure_SW3
END SELECT
My project is using an LCD and a PIC16F870. I think I need tables of some sort and thought this might be the right direction. I would like to put some LCD messages out based on the conditions of 3 or 4 inputs pins and probably have 2 or 3 output pins besides the LCD out.
I have a question about your code. I am using the LCD routine and PORTB.3 is being used by it. Let's say I want:
___________________________
MaskSwitch=PORTB & $07
SELECT CASE MaskSwitch
CASE 16 '%00010000 or SW1
Goto Message_1
___________________________
I need an input on PORTB.4. as well as 0-2. Is this feasable or will the that disrupt PORTB.3 in any way and mess up my LCD_Out routine?
Also I would need to have something like CASE 16 but I need to ignore %00010XXX (PORTB 0-2). Do I have to build a case for each of the 3 Bin inputs I want to ignore? I think so, but not sure. Or can I exclude them somehow?
How about a CASE 0 ' or %00000000 ? Is that a valid case?
What's the "& %07" after the PORTB for? Setting the Input/ouptuts on PORTB? How can I do this beyond PORTB.3 without upsetting the LCD routine on PORTB.3 (Enable for the LCD?)?
Appreciated
Ultra new at PBP & Programming