Microsoft Small Basic

Program Listing: JBF006
'Timer WK Version 1.0
' Timer can be used with Makey Makey
' Timer is activated by holding down the mouse left button
GraphicsWindow.BrushColor = "cyan"
GraphicsWindow.BackgroundColor = "blue"
GraphicsWindow.FontSize = 25
GraphicsWindow.DrawText(60,70,"Hours : Minutes : Seconds")
Hour = 0
Minute = 0
Seconds = 0
Timer.Interval = 1000 'One second
Timer.Tick = Refresh_Display

Sub Refresh_Display
GraphicsWindow.FontSize = 90
GraphicsWindow.BrushColor = "blue"
GraphicsWindow.FillRectangle(50, 100, 500, 100)
GraphicsWindow.BrushColor = "cyan"
GraphicsWindow.DrawText(75, 90, ElapsedTime)

If Mouse.IsLeftButtonDown="True" Then
Seconds = Seconds + 1
EndIf

If Seconds > 59 Then
Minute = Minute + 1
Seconds = 0
EndIf

If Minute > 59 Then
Minute = 0
Hour = Hour + 1
EndIf

If Hour < 10 Then
ElapsedTime = "0" + Hour + ":"
Else
ElapsedTime = Hour + ":"
EndIf

If Minute < 10 Then
ElapsedTime = ElapsedTime + "0" + Minute + ":"
Else
ElapsedTime = ElapsedTime + Minute + ":"
EndIf

If Seconds < 10 Then
ElapsedTime = ElapsedTime + "0" + Seconds
Else
ElapsedTime = ElapsedTime + Seconds
EndIf

EndSub