Im doing a pic based connect 4 using a led matrix for my senior project in high school. I am very novice at coding so please make sure to keep that in mind while critiquing my work. All i want it to do for now is to have a light at the top left to be on and when you push a button it falls down and stops at the bottom,then when you press a button again another one falls on top of that and so on. I have the first led falling but after the led stops it starts stacking until the whole left column is on. I don't know how this is possible when i have
if (b.0[rows]=0)then fall=0 : goto main
it acts if it keeps going through the loop main. Any suggestions?
Code:fall var byte Shift var byte pb1 var porta.0 pb2 var porta.1 rowvar var byte b var byte rows var byte stack var byte row1 var byte row2 var byte row3 var byte row4 var byte row5 var byte row6 var byte row7 var byte ansel=0 anselh=0 fall = 0 Shift = 7 down=1 portb=b rows=0 stack=0 trisA=111111 trisb=000000 trisc=000000 trisd=000000 b=~000000 portc=000001 portd=000000 loopa: portb=b+b1 portb=b pause 500 if (pb1==0 & b.7==0) then fall=1 if (fall==1) then b.0[Shift] = 1 b.0[Shift - 1] = 0 Shift = Shift - 1 endif if (b.0[rows]=0)then fall=0 : goto main goto loopa main: portb=b rows=rows+1 if rows=6 then rows=0 if stack=6 then stack=5 if stack = 0 then b=~000010 if stack = 1 then b=~000110 if stack = 2 then b=~001110 if stack = 3 then b=~011110 if stack = 4 then b=~111110 if stack = 5 then b=~111110 portc=000001 stack=stack+1 goto loopa




Bookmarks