Microsoft Small Basic

Program Listing:
Embed this in your website
' Traffic signal by NaochanON 2014/09/02

GUI()

While "True"
  td=Math.Floor((Clock.ElapsedMilliseconds-t0))/1000   '**.***
  CLR= Text.GetSubText(TimeSc,math.Ceiling(td),1)
  GraphicsWindow.Title=math.Floor(td*10)/10 +" sec Color= "+  color[2][CLR]
  If CLR<>lastNMB Then
    Shapes.SetOpacity(Signal[color[2][lastNMB]],20)
    Shapes.SetOpacity(Signal[color[2][CLR]],100)
  EndIf
  lastNMB=CLR
  If td>13 Then
    t0=clock.ElapsedMilliseconds
  EndIf
endwhile

Sub GUI
  GraphicsWindow.BackgroundColor="LightCyan"
  color[1]="1=DarkGray;2=DarkGray;3=DarkGray
  color[2]="1=Red;2=Yellow;3=Blue"
  Pos[1]["X"]="1=200;2=200;3=200"
  pos[1]["Y"]="1=20;2=80;3=200"
  pos[2]["X"]="1=220;2=220;3=220"
  pos[2]["Y"]="1=40;2=130;3=220"
  size="1=120;2=80;3=180"
  For i=1 To 2
    For j=1 To 3
      GraphicsWindow.BrushColor=color[i][j]
      GraphicsWindow.PenColor=color[i][j]
      If i=1 and j=2 Then
        Signal[color[i][j]]=Shapes.Addrectangle(size[i],size[3])
      Else
        Signal[color[i][j]]=Shapes.AddEllipse(size[i],size[i])
        If i=2 then
          Shapes.SetOpacity( Signal[color[i][j]],20)
        endif
      EndIf
      Shapes.Move( Signal[color[i][j]], Pos[i]["X"][j], Pos[i]["Y"][j])
    EndFor
  EndFor
  TimeSc="3333322211111"        ' Blue 5sec Yellow 3sec Red 3sec
  t0=clock.ElapsedMilliseconds
EndSub

Copyright (c) Microsoft Corporation. All rights reserved.