J A Hawtin
Member
Attached is a bit of code I’m having a problem getting to run. In actual fact its two bits of code put together. The first bit is scanning a keypad for the number entered and the second bit outputs that number to a seven segment display. (This is just part of a project I’m working on but I need to get it working before I go any further). Both bits of code work because I’ve used them before in previous programs. Albeit on a 28X1 picaxe. This time I’m using a 28X2. Pins B0 to B3 scan the rows on the keypad and pins B4 to B7 output to the display driver 4511B. Can anyone please tell me where I’m going wrong? The other couple of lines of code store the last number entered and reload it to the display on power up.
Code:
power on:
read 0 b1
pinsB = b1
let dirsB = %11111111
symbol row = b4
symbol key = b5
init:
pause 500
main:
key = 0
for row = 0 to 3
high row
gosub keyscan
low row
if key = 1 then gosub route1
if key = 2 then gosub route2
if key = 3 then gosub route3
if key = 4 then gosub route4
if key = 5 then gosub route5
if key = 6 then gosub route6
if key = 7 then gosub route7
if key = 8 then gosub route8
if key = 9 then gosub route9
next row
goto main
keyscan:
if pinC.1 = 1 then
key = row * 3 + 1
do loop while pinC.1 = 1
elseif pinC.2 = 1 then
key = row * 3 + 2
do loop while pinC.2 = 1
elseif pinC.3 = 1 then
key = row * 3 + 3
do loop while pinC.3 = 1
endif
return
route1: let b1 = 1
let pinsB=b1
goto saveLastRoute
return
route2: let b1 = 2
let pinsB=b1
goto saveLastRoute
return
route3: let b1 = 3
let pinsB=b1
goto saveLastRoute
return
route4: let b1 = 4
let pinsB=b1
goto saveLastRoute
return
route5: let b1 = 5
let pinsB=b1
goto saveLastRoute
return
route6: let b1 = 6
let pinsB=b1
goto saveLastRoute
return
route7: let b1 = 7
let pinsB=b1
goto saveLastRoute
return
route8: let b1 = 8
let pinsB=b1
goto saveLastRoute
return
route9: let b1 = 9
let pinsB=b1
goto saveLastRoute
return
saveLastRoute:
Write 0,b1
return
goto main