SlotForum banner
1 - 7 of 7 Posts

·
Registered
Joined
·
134 Posts
Discussion Starter · #1 ·
Hi,

I recently resurrected an old laptop and installed BASIC-256.
It took me back to playing around with my ZX Spectrum in the 1980s!
The laptop is running a Linux based operating system and I can't seem to get it to work with Windows based timing programs.

So I thought I'd have a go at making a timing program for rally stages myself!

You'll need to download and install BASIC-256 (see link above) for it to work and then copy and paste the program below.
The car is counted by pressing the right mouse button (an old mouse could be converted to attach a 'switch' to the start/finish line).

#Slot Rally Stage Timer 2011 v1.01
#written in BASIC-256
#by Alan Murrell
rallystagetimer:
cls
clg
colour red
rect 30,0,250,35
colour white
font "times" ,20,100
text 35,0, "Rally Stage Timer"
print "Move mouse to Graphics Output area"
say "move mouse 2 graphics output area"
say "how many laps"
input "How many laps?", distance
say distance+"laps"
starter=5
x=50
clg
countdownloop:
for x=50 to 260 step 52
if clickb=2 then goto falsestart
clickclear
colour red
circle x,50,25
say starter
starter=starter-1
pause 1
if starter<1 then goto start
next x
start:
if clickb=2 then goto falsestart
clickclear
colour green
for x=50 to 260 step 52
circle x,50,25
next x
say "go"
tenths=0
laps=distance
goto timeloop
falsestart:
cls
clg
colour red
font "times" ,20,100
text 35,0, "FALSE START"
pause 1
text 35,25, "RE-STARTING"
starter=5
x=50
pause 2
clickclear
cls
clg
goto countdownloop
timeloop:
#pause 0.06 represents 0.1 seconds please adjust to suit your pc
tenths=tenths+.1
if tenths<3.0 then laps=distance #ignores lap counting for first 3 seconds
colour red
font "times",25,100
text 0,100, "Time"
text 0,125, tenths
text 100,75, "Laps"
text 100,100,"remaining"
text 100,125, laps
If laps = 0 then goto results
if clickb=2 then laps=laps-1
clickclear
pause 0.06
clg
goto timeloop
results:
cls
print distance+" laps in "+tenths+" seconds"
say distance
say "laps in"
say tenths
say "seconds"
raceagain:
say "do you want to race again"
input "Do you want to race again? ",k$
if k$="y" then goto rallystagetimer
if k$="Y" then goto rallystagetimer
if k$<>"y" then goto clearscreens
if k$<>"Y" then goto clearscreens
clearscreens:
cls
clg
end
 

·
Registered
Joined
·
134 Posts
Discussion Starter · #2 ·
Had a re-think how program worked.
Re-written so that it creates an array so logs all the lap times, adds them up for total time (useful for rally stages) and works out the average lap time.
Now it starts when the car crosses the line so no jump start routine required.

Also made a timing bridge and switch using an old keyboard and a 741 chip and reed relay.
The laptop thinks an external keyboard is connected and laps are counted each time the number '1' is pressed.

Timing bridge:


Switch circuit:

(yes it is in a take away box!) Black lead (USB) goes to the PC, powers circuit (5v), takes the signal and powers a white LED in the bridge.
White lead, from an old mouse, goes to the LDR and power to the LED.

Display after the stage has been completed:


Video of program working:
Video of program on Blogger
(I hope it works)

Program, just copy and paste into a downloaded copy of Basic 256.

#Lap Counter v212
#by Alan Murrell October 2011
Lapcounter:
fastgraphics
cls
clg
graphsize 400,400

colour red
rect 30,0,175,20
colour white
font "arial" ,10,100
text 35,5, "Rally Stage Timer"
refresh
x=0

colour black
font "arial" ,10,100
text 35,25, "How many laps?"
input nlaps
text 200, 25, nlaps
refresh
dim race(nlaps)

startline:

colour black
font "arial" ,10,100
text 35,45, "When you are ready........"
colour green
font "arial", 25,100
text 250,30, "GO"
refresh
cls
k = key
if k = asc("1") then goto goroutine
goto startline

goroutine:
sound 300,100

laptimeroutine:
time = 0
refresh
startkeypressroutine:
pause 0.1
cls
k = key
time=time+0.1
#print time
if k = asc("1") then goto counting
goto startkeypressroutine

counting:
if time <6 then goto startkeypressroutine
sound 300,100
x=x+1
colour red
rect 240,0,245,20
colour black
font "arial" ,10,100
text 250,5, "Lap "+x
refresh
race[x-1]=time
if x=nlaps then goto results
goto laptimeroutine

results:
sound 400,100
sound 500,100
cls
totaltime = 0
for column = 0 to nlaps-1
totaltime = totaltime + race[column]
colour blue
font "arial " ,10,100
text 35,(80+(column*20)), "Lap "+(column+1)+" "+race[column]
next column

text 35, (90+(nlaps*20)), "Average time "+totaltime / nlaps+ " secs"
colour red
text 35, (110+(nlaps*20)), "Total time "+totaltime+ " secs"
colour black
text 35, (140+(nlaps*20)), "Do you want to race again?"
input r$
if r$="y" then goto Lapcounter
if r$="Y" then goto Lapcounter
if r$<>"y" then goto clearscreens
if r$<>"Y" then goto clearscreens

clearscreens:
refresh
cls
clg
end
 

·
Registered
Joined
·
605 Posts
Hi speedyroadster

Got to give you credit for your efforts! I guess you have "recycled" all the parts that you had lying around to create your lap counter, I like that


Its good when you come up with something from odds and sods and its my style too!

Have you considered writing your program in Windows? maybe VB or something? I'm sure you will get it to work on that platform too

Cheers!

Richard
 

·
Registered
Joined
·
134 Posts
Discussion Starter · #4 ·
Thanks Richard, I wish I knew how to program in VB or something else! Basic 256 doesn't (as far as I know) create .EXE type files but it can be installed on Windows which you'll need if you want to run anything written in Basic.

And before you ask, no I don't eat that many take-aways, the box was just the right size and made adjusting the variable resistor easier!!


Regards,

Alan
 

·
Registered
Joined
·
134 Posts
Discussion Starter · #6 ·
I've pretty much finished my lap counting project (lighting bridge, control box, program) so I'd thought I'd share with the forum.

Light Bridge:


The bridge has two Light Dependent Resistors and two bridge LEDs, a 741 Op amp compares the resistance and then sends an output when the lower LDR's resistance changes to the control box.

Control Box:

Inside the box is the circuit board from an old USB keyboard, the output triggers a Reed Relay (from Maplins) which sends a signal via the keyboard circuit board to the program.
The Control Box cover has labels Trigger/Count, Option A, B, C, Start and Stop. In reality, they are buttons 1,2,3,4, F5 and Shift.
By pressing F5 (Start) the program starts, holding Shift (Stop) and F5 (Start) the program stops.
Pressing 1 (Trigger/Count) triggers laps (in case the car doesn't trigger the light bridge). These is a 3 second time period before the program will accept another trigger to prevent false counting.
Pressing 2,3,4 (Option A,B,C) selects the number of laps (at the start) and restart options (re-race, change race duration, quit) at the end.

If you want to try the program, you need to install BASIC 256 (Google search) and just copy and paste the following:

#Lap Counter v310
ts = 15
cls
clg
Lapcounter:
editvisible false
outputvisible false
cls
clg
graphsize 400,500
colour black
rect 0,0,400,500
colour white
rect 2,2,396,496
colour red
rect 30,0,175,25
colour white
font "arial" ,ts,100
text 35,0, "Rally Stage Timer"
x=0
lapinput:
colour black
font "arial" ,10,100
text 35,25, "How many laps?"
text 35,39, "Press A for single lap"
text 35,53, "Press B for 6 laps"
text 35,66, "Press C for 10 laps"
laps = key
if laps = asc ("2") then goto displayracedis1
if laps = asc ("3") then goto displayracedis6
if laps = asc ("4") then goto displayracedis10
gosub lapinput
displayracedis1:
sound 400,50
nlaps = 1
goto displayracedis
displayracedis6:
sound 400,50
nlaps = 6
goto displayracedis
displayracedis10:
sound 400,50
nlaps = 10
goto displayracedis
displayracedis:
text 200, 25, nlaps
dim race(nlaps)
startline:
colour black
font "arial" ,10,100
text 250,25, "When you are ready"
colour red
font "arial", 30,100
text 275,37, "GO"
circle 265,90,10
circle 287,90,10
circle 309,90,10
circle 331,90,10
circle 353,90,10
cls
k = key
if k = asc("1") then goto youareracing
goto startline
youareracing:
colour green
text 275,37, "GO"
circle 265,90,10
circle 287,90,10
circle 309,90,10
circle 331,90,10
circle 353,90,10
goroutine:
sound 300,100
laptimeroutine:
time = 0
startkeypressroutine:
pause 0.1
cls
k = key
time=time+0.1
if k = asc("1") then goto counting
goto startkeypressroutine
counting:
if time <3 then goto startkeypressroutine
sound 300,100
x=x+1
colour red
rect 240,0,145,25
colour black
font "arial" ,ts,100
text 250,0, "Lap "+x
race[x-1]=time
if x=nlaps then goto results
goto laptimeroutine
results:
sound 400,100
sound 500,100
cls
resultsonly:
totaltime = 0
for column = 0 to nlaps-1
totaltime = totaltime + race[column]
colour blue
font "arial " ,ts,100
text 35,(80+(column*20+ts)), "Lap "+(column+1)+" "+race[column]
next column
text 35, (90+(nlaps*20+ts)), "Average time "+totaltime / nlaps+ " secs"
colour red
font "arial" ,ts,100
text 35, (112+(nlaps*20+ts)), "Total time "+totaltime+ " secs"
colour black
font "arial", 10,100
text 35, (152+(nlaps*20)), "Do you want to race again?"
text 35, (166+(nlaps*20)), "Press A to race with the same number of laps"
text 35, (180+(nlaps*20)), "Press B to change the number of laps"
text 35, (194+(nlaps*20)), "Press C to quit"
q = key
if q= asc("2") then goto restart
if q= asc("3") then goto Lapcounter
if q= asc("4") then goto clearscreens
goto resultsonly
restart:
x=0
clg
colour black
rect 0,0,400,500
colour white
rect 2,2,396,496
colour red
rect 30,0,175,25
colour white
font "arial" ,ts,100
text 35,0, "Rally Stage Timer"
colour black
text 35,25, nlaps+" Lap race"
sound 400,100
sound 500,100
goto startline
clearscreens:
cls
clg
end
 
1 - 7 of 7 Posts
Top