Something like this is where LOOKUP2 comes in handy.
Code:
@ DEVICE PIC16F88, WDT_OFF,INTRC_OSC,MCLR_OFF,BOD_ON,LVP_OFF,PWRT_ON,PROTECT_OFF
DEFINE OSC 8
DEFINE NO_CLRWDT 1
OSCCON = %01110000 ' 8MHz
CMCON = 7 ' disable analog comparators
ANSEL = 0 ' disable A/D module, all digital
X VAR WORD
Index VAR BYTE
LED VAR PORTB.0
TRISA = %00111100 ' RA2 to RA5 inputs for DIP switch
PORTB = 0
TRISB = %11111110 ' RB0 for LED
OPTION_REG = %11111111
WHILE OSCCON.2 = 0 ' wait for internal osc stable before moving on
WEND
Main:
Index = (PORTA >> 2) & $0F ' Read DIP switch AND mask result
LOOKUP2 Index,[200,300,400,500,600,700,800,900,1000,2000,_
3000,4000,5000,6000,7000,8000],X
HIGH LED
PAUSE X
LOW LED
PAUSE X
GOTO Main
END
Change the delay periods in the table to suite your app.
Bookmarks