MrDEB
Well-Known Member
Benn hacking at this code for several days but still can't get portb.6 and 7 to work correctly.
Tried chanhing the toggle routing (PRESS or PRESS2) all i does is turns on two different leds.
thinking a short but no.
using PRESS() LED 6 & 7 are ON. using PRESS2() LED1 & 2 are ON. both without a button press.
code is using SWORDFISH
Tried chanhing the toggle routing (PRESS or PRESS2) all i does is turns on two different leds.
thinking a short but no.
using PRESS() LED 6 & 7 are ON. using PRESS2() LED1 & 2 are ON. both without a button press.
code is using SWORDFISH
Code:
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/10/2022 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/9/2022 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
Device = 18F43k22 ' Tell the compiler what chip we are using
Clock = 8 ' Tell the compiler what we will be setting the clock to (Mhz)
#OPTION DIGITALLIO_INIT=TRUE
Include "SetDigitalIO.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
Include "utils.bas"
Include "convert.bas"
Include "intosc.bas"
Dim y As Byte
Dim x As Byte
Dim Player As Byte
Dim counter As Byte
Dim Switch As PORTE.1
//PLAYER LEDS
Dim led1 As PORTA.0
Dim led2 As PORTA.1
Dim led3 As PORTA.2
Dim led4 As PORTA.3
Dim led5 As PORTA.4
Dim led6 As PORTA.5
Dim led7 As PORTA.6
Dim led8 As PORTA.7
//player buttons
Dim Button0 As PORTB.0
Dim Button1 As PORTB.1
Dim Button2 As PORTB.2
Dim Button3 As PORTB.3
Dim Button4 As PORTB.4
Dim Button5 As PORTB.5
Dim Button6 As PORTB.6
Dim Button7 As PORTB.7
Dim Battery As PORTA.2 'hlvd
Dim Power As PORTA.1 'hlvd
SUB PRESS()
if button0 = 0 then toggle (led1) end if
if button1 = 0 then toggle (led2) end if
if button2 = 0 then toggle (led3) end if
if button3 = 0 then toggle (led4) end if
if button4 = 0 then toggle (led5) end if
if button5 = 0 then toggle (led6) end if
if button6 = 0 then toggle (led7) end if
if button7 = 0 then toggle (led8) end if
end sub
SUB PRESS2()
if button0 = 0 then toggle (led1) end if
if button1 = 0 then toggle (led2) end if
if button2 = 0 then toggle (led3) end if
if button3 = 0 then toggle (led4) end if
if button4 = 0 then toggle (led5) end if
if button5 = 0 then toggle (led6) end if
if button6 = 0 then toggle (led1) end if
if button7 = 0 then toggle (led2) end if
end sub
Sub Player_Press()
Select(Player)
Case 1 Button0=0 Toggle(led1)
Case 2 Button1=0 Toggle(led2)
Case 3 Button2=0 Toggle(led3)
Case 4 Button3=0 Toggle(led4)
Case 5 Button4=0 Toggle(led5)
Case 6 Button5=0 Toggle(led6)
Case 7 Button6=0 Toggle(led7)
Case 8 Button7=0 Toggle(led8)
End Select
End Sub
SETALlDigital // Make all Pins digital I/O's
TRISA=0
'TRISC = 0 // LED port - all outputs
'TRISD=0
TRISB = $FF // SW port - all inputs
WPUB = $FF // PORTB pullup mask - all PORTB pullups
INTCON2.bits(7) = 0 // RBPU bit - turn on pullups
'TRISC = %00000000 // Make PORTC all outputs COLUMS ON MATRIX
'TRISA = %00000000 //PLAYER LEDS
'TRISD = %00000000 //MATRIX ROWS
x = 0
y = 0
'Switch = 1
Input (Switch) // counter button
'Switch = 1
//PLAYER LEDS PORTA
Output (led1)
Output (led2)
Output (led3)
Output (led4)
Output (led5)
Output (led6)
Output (led7)
Output (led8)
{
//PLAYER INPUT BUTTONS
Input(Button0)
Input(Button1)
Input(Button2)
Input(Button3)
Input(Button4)
Input(Button5)
Input(Button6)
Input(Button7)
}
//HLVD
Output (Battery)
Output (Power)
led1 =0
led2 =0
led3 =0
led4 =0
led5 =0
led6 =0
led7 =0
led8 =0
Input(Switch) //PORTE.1
counter = 12
Player=0
While true
press2()
'TEST()
' Player_Press()
Wend