MrDEB
Well-Known Member
I am starting out with swordfish code to read a 4 x 4 switch matrix but something is wrong with my case select
It shows an incompatible type error? I tried inserting comas etc but?? Maybe just go with a bunch of IF THEN statements??
It shows an incompatible type error? I tried inserting comas etc but?? Maybe just go with a bunch of IF THEN statements??
DEVICE = 18F24k20 ' Tell the compiler what chip we are using
CLOCK = 8 ' Tell the compiler what we will be setting the clock to (Mhz)
CONFIG MCLRE = OFF
CONFIG fOSC = INTIO67 ' Internal oscillator, IO on pins 6 and 7
#option LCD_DATA = PORTC.4
#option LCD_RS = PORTC.0
#option LCD_EN = PORTC.1
INCLUDE "SetDigitalIO.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
INCLUDE "utils.bas"
INCLUDE "convert.bas" //xxxxx
INCLUDE "LCD.bas"
INCLUDE "Keypad16pullup.bas"
INCLUDE "utils.bas"
// import LCD library...
DIM Button_Press AS WORD
/////////////////
//SWITCHES ON PORTB
//ZZZZZZZZZZZZZZZZZ
DIM COLUM1 AS PORTB.0
DIM COLUM2 AS PORTB.1
DIM COLUM3 AS PORTB.2
DIM COLUM4 AS PORTB.3
////////////////////
//INPUTS FROM SWITCH MATRIX
////////////////////////
DIM ROW1 AS PORTB.4
DIM ROW2 AS PORTB.5
DIM ROW3 AS PORTB.6
DIM ROW4 AS PORTB.7
DIM Round_total AS WORD
DIM Total_Score AS WORD
DIM Sum AS WORD
// program start...
SetAllDigital
Cls
colum1= 1
colum2= 1
colum3= 1
colum4= 1
row1= 1
row2= 1
row3= 1
row4= 1
'WriteAt(1,1,"Hello World") //CHANGE AS NEEDED
WHILE TRUE
SELECT Button_Press
CASE 1 COLUM1 = 0 AND ROW1 =0 Sum = 1
CASE 2 COLUM2 = 0 AND ROW1 =0 Sum = 2
CASE 3 COLUM3 = 0 AND ROW1 =0 Sum = 3
CASE 4 COLUM4 = 0 AND ROW1 =0 Sum = 4
CASE 5 COLUM1 = 0 AND ROW2 =0 Sum = 5
CASE 6 COLUM2 = 0 AND ROW2 =0 Sum = 6
CASE 7 COLUM3 = 0 AND ROW2 =0 Sum = 7
CASE 8 COLUM4 = 0 AND ROW2 =0 Sum = 8
CASE 9 COLUM1 = 0 AND ROW3 =0 Sum = 9
CASE 10 COLUM2 = 0 AND ROW3 =0 Sum = 10
CASE 11 COLUM3 = 0 AND ROW3 =0 Sum = 11
CASE 12 COLUM4 = 0 AND ROW3 =0 Sum = 12
CASE 13 COLUM1 = 0 AND ROW4 =0 Sum = 0
CASE 14 COLUM2 = 0 AND ROW4 =0 Sum = 50
CASE 15 COLUM3 = 0 AND ROW4 =0 Sum = Round_total
CASE 16 COLUM4 = 0 AND ROW4 =0 Sum = Total_Score
END SELECT
WEND