It has been harder than I thought. This whole debugging period is really stealing so much time off of me.
I have prepared a pseudo code of what we should do before going into the PicBasic Pro here you can see it:
‘get the value stored in a variable (this is going to be the value of the first led)
‘check one row up/down/right/left is on or off state
if on ‘check one row up/down/right/left is on or off state
‘get the value stored in a variable (this is going to be the value of the second led)
‘check those variables are in a proper horizontal or a vertical axis at all.
‘get the pin of the LED that can be pressed and store in a variable.
break; if off
‘get the pin value from the global variable and light it and turn off the previous ones.
Here is the code I have for the proto type we are trying to prepare with David today. Basically It was supposed to be a working example of a 9 LED series, which are in a plus shape position, I have managed to make it work on the first move which is the middle is empty and you force your piece to go jump over the one below the middle, with your two switch. When I tried to extend the code for the second movement, it didn’t work out. I need to ask question regarding this.
TRISB = %11111111 ‘To keep all the PORTB as an input
TRISC= %00000000 ‘Same sense, PORTC is set to output.
TRISD = %11110000
state var word ‘State variable is there to be the flag.
PORTC = %11111011
PORTD = %11111111
‘if switch bottom is pressed
if PORTB.0 then
‘put a flag that it is pressed with the state variable
state = 1
’ the middle button is pressed and our state is 1
IF PORTB.2 and state == 1 THEN
’ do readfirst subroutine
IF PORTB.3 and state == 2 then
if portb.1 and state == 3 then
‘check if middle led is turned off
IF PORTC.2 == 0 then
‘if it is turned off then make the bottom led and the
one above it turned off
‘problem here, should I set the others led again to
‘they were high in the setup??
‘change our state to 2 in case not to worry about this
‘this subroutine is making one of my leds going to 0 state, I suspect it is just processing its if statement ‘above and making this sub work and thus leaving my LED in that position.
if portc.1 == 0 then