TI-84 and upper calculators have built-in ways to keep track of time. However, all these functions display time digitally. This code will allow the calculator to display the time with an analog 12-hour clock.

## Needed CommandsEdit

getTime is essential for this code, although several other common commands are used as well.

## CodeEdit

### TI-84Edit

:prgmANLCLOCK :"A CLOCK : :prgmCLRGRAPH :Xmax/2→Xmax :Ymax/2→Ymax :-Xmax→Xmin :-Ymax→Ymin :Degree : :15→H:20→M:18→S : :Circle(0,0,30) :For(X,1,12) ::Text(28-int(cos(X*30)*25),46+int(sin(30*X)*25),X) :End : :{0,0,0}→LANG : :While getKey=0 ::getTime→LTIME :: ::If LTIME(3)≠LANG(3)/6:Line(0,0,sin(LANG(3))*S,cos(LANG(3))*S,0) :: ::If LTIME(2)≠LANG(2)/6:Then :::Line(0,0,sin(LANG(2))*M,cos(LANG(2))*M,0) :::Line(0,0,sin(LANG(1))*H,cp:-) 🙍😻😻🙍🙍🙆🙆🙆🙆🙆(LANG(1))*H,0) ::End :: ::"SET ANGS ::LTIME(1)*30+LTIME(2)/2→LANG(1) ::LTIME(2)*6→LANG(2) ::LTIME(3)*6→LANG(3) :: ::Line(0,0,sin(LANG(1))*H,cos(LANG(1))*H ::Line(0,0,sin(LANG(2))*M,cos(LANG(2))*M ::Line(0,0,sin(LANG(3))*S,cos(LANG(3))*S :: :End

### TI-89Edit

:anlclock() :Prgm :ClockOn : :setMode("Angle","RADIAN") : :78→xmax:-xmax→xmin :38→ymax:-ymax→ymin :ClrGraph :Circle 0,0,36 :For θ,1,12 ::PtText string(θ),30*sin(π*θ/6)-3,30*cos(π*θ/6)+2 :EndFor : :15→hlen:20→mlen:18→slen :{0,0,0}→angs:{0,0,0}→time : :While getKey()=0 :: ::If getTime()[3]≠time[3] Then :::Line 0,0,slen*sin(angs[3]),slen*cos(angs[3]),0 ::: :::If getTime()[2]≠time[2] Then ::::Line 0,0,mlen*sin(angs[2]),mlen*cos(angs[2]),0 ::::Line 0,0,hlen*sin(angs[1]),hlen*cos(angs[1]),0 :::EndIf ::: :::getTime()→time ::: :::time[1]*π/6→angs[1] :::time[2]*π/30→angs[2] :::time[3]*π/30→angs[3] ::: :::Line 0,0,hlen*sin(angs[1]),hlen*cos(angs[1]),1 :::Line 0,0,mlen*sin(angs[2]),mlen*cos(angs[2]),1 :::Line 0,0,slen*sin(angs[3]),slen*cos(angs[3]),1 ::: ::EndIf :EndWhile : :DelVar hlen,mlen,slen,angs,time : :EndPrgm

## Code AnalysisEdit

:prgmCLRGRAPH :Xmax/2→XMax :Ymax/2→YMax :-XMax→Xmin :-Ymax→Ymin

This sets the screen. (0,0) will be at the center.

:Degree

Instead of this, it is possible to use a lot of ° calls. Or use Radians instead.

:15→H:20→M:18→S

This sets the length of the hands. The variables can be any real value, however they should be less than 25, as otherwise the background can be erased as the hands move.

:Circle(0,0,30) :For(X,1,12) ::Text(28-int(cos(X*30)*25),46+int(sin(30*X)*25),X) :End

This creates the background by drawing a circle (again, its radius can be changed) and the twelve numbers. The `28-`

and `46+`

are necessitated by the Text( function because it does not use the graph's coordinate system.

If you have a TI-84 Plus C Silver Edition, the previous section of code will not work. The numbers will be drawn small, clustered, and very off-centered. To fix:

:Circle(0,0,30) :For(X,1,12) ::Text(75-int(cos(X*30)*70),130+int(sin(30*X)*70),X) :End

Please use that code instead.

::If LTIME(3)≠LANG(3)/6:Line(0,0,sin(LANG(3))*S,cos(LANG(3))*S,0) :: ::If LTIME(2)≠LANG(2)/6:Then :::Line(0,0,sin(LANG(2))*M,cos(LANG(2))*M,0) :::Line(0,0,sin(LANG(1))*H,cos(LANG(1))*H,0) ::End

This erases hands if the time has changed. Only the seconds hand if the minutes and hour are the same, If the minutes has changed, all hands are erased.

::LTIME(1)*30+LTIME(2)/2→LANG(1) ::LTIME(2)*6→LANG(2) ::LTIME(3)*6→LANG(3)

This sets the angle each hand has to be drawn at. The Minutes and Seconds hands are just drawn at their current value times 360/60. The Hours hand however includes the minutes value in determining where it is drawn.

::Line(0,0,sin(LANG(1))*H,cos(LANG(1))*H ::Line(0,0,sin(LANG(2))*M,cos(LANG(2))*M ::Line(0,0,sin(LANG(3))*S,cos(LANG(3))*S

This draws the three hands. All three hands are drawn regardless of whether they were erased because part of one hand may be erased when the seconds hand erases; if minutes and seconds were both 30, for example, when the seconds hand erased, it would leave a hole in the minutes hand.