Generate a Square Wave

while True:
   togglePin()
   sleep(half_period)