ashawthing
New Member
I am trying to design and make an electronic snooker scoreboard with an IR hand-held transmitter. There will be the main scoreboard unit on the wall, each players score will be displayed on 2 sets of 3 seven segment displays. There will then be a small hand-held unit with a keypad. Each time a ball is potted the referee will press the number on the keypad corresponding to the appropriate points for the ball potted. There will also be a button to -1 from the count and reset both scores for a new game.
I have put this code together for the transmitter using a picaxe-14m
The code that figures out the keypad input has pretty much been taken from one of the examples on the programming editor.
I am interested on getting your thoughts on the code for sending the ir information. I plan on having a toggle switch setting input0 to 1/0, this determines which player is scoring and which score to increase the count of. I have just set the infraout data to key_value for player1 and key_value+12 for player2 (there are 12 possibilities for player1 so the first 12 infraout data values are taken).
There are no syntax errors from the programming editor but can anyone see anything that looks wrong. I am a relative novice so any advice is welcome
I have put this code together for the transmitter using a picaxe-14m
Code:
' Snooker score board IR remote
' output 1 - row 1
' output 2 - row 2
' output 3 - row 3
' output 4 - row 4
' input 0 - defines which player is scoring
' input 1 - column 1
' input 2 - column 2
' input 3 - column 3
symbol key_value = b0
polling:
let key_value = 0
let pins = %00000010
gosub key_test
let key_value = 3
let pins = %00000100
gosub key_test
let key_value = 6
let pins = %00001000
gosub key_test
let key_value = 9
let pins = %00010000
gosub key_test
goto polling
' key_value will now be 0,3,6 or 9. Add 1,2 or 3 to this to get the correct key_value
' return if no key has been pressed
key_test:
if pin1 = 1 then add1
if pin2 = 1 then add2
if pin3 = 1 then add3
return
add1: let key_value = key_value + 1
add2: let key_value = key_value + 2
add3: let key_value = key_value + 3
' Now transmit the information using infraout
if pin0 = 0 then transmit_player1
goto transmit_player2
transmit_player1:
for b1 = 1 to 10
infraout 1,key_value
pause 45
next b1
goto polling
transmit_player2:
key_value = key_value + 12
for b1 = 1 to 10
infraout 1,key_value
pause 45
next b1
goto polling
I am interested on getting your thoughts on the code for sending the ir information. I plan on having a toggle switch setting input0 to 1/0, this determines which player is scoring and which score to increase the count of. I have just set the infraout data to key_value for player1 and key_value+12 for player2 (there are 12 possibilities for player1 so the first 12 infraout data values are taken).
There are no syntax errors from the programming editor but can anyone see anything that looks wrong. I am a relative novice so any advice is welcome