APL (35)
(Yes, it does fit in 35 bytes, here's a 1-byte APL encoding)
{∇⍵+⌈⎕DL.05⊣⎕←'|'↑⍨-21+⌈20×1○⍵×.1}1
Explanation:
{
...}
1: call the function with 1 at the beginning1○⍵×.1
: close enough for government work tosin(⍵×π÷30)
. (1○
issin
).-21+⌈20
: normalize to the range1..40
and negate'|'↑⍨
: take the lastN
characters from the string'|'
(which results in a string of spaces with a|
at the end⎕←
: display⌈⎕DL.05
: wait 50 ms and return1
. (⎕DL
returns the amount of time it actually waited, which is going to be close to0.05
, rounding that value up gives1
).∇⍵+
: add that number (1
) to⍵
and run the function again.