In[]:=
PixelClock[pixelTime_,gapTime_]:=Piecewise[{{1,Mod[#,pixelTime]<(pixelTime-gapTime)}},0]&
In[]:=
pc1=PixelClock[Quantity[20,"Microseconds"],Quantity[2,"Microseconds"]]
Out[]=
1
Mod#1,
20
μs
<
20
μs
-
2
μs
0
True
&
In[]:=
pc1[Quantity[#,"Microseconds"]]&/@Range[100]
Out[]=
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1}
In[]:=
Plot[pc1[x],{x,Quantity[0,"Microseconds"],Quantity[100,"Microseconds"]},Filling->Axis]
Out[]=
In[]:=
Plot[pc1[Quantity[x,"Microseconds"]],{x,0,100},Filling->Axis]
Out[]=
In[]:=
Plot[pc1[x],{x,Quantity[0,"Microseconds"],Quantity[0.0001,"Microseconds"]},Filling->Axis]
Out[]=
In[]:=
pc2=PixelClock[20,2]
Out[]=
1
Mod[#1,20]<20-2
0
True
&
In[]:=
pc2[#]&/@Range[100]
Out[]=
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1}
In[]:=
Plot[pc2[x],{x,0,100},Filling->Axis]
Out[]=
In[]:=
​