'''
Description: Onboard Timer Pattern Program.
Author     : M.Pugazhendi
Date       : 03rdJul2021

A. The timer_one is used for changing the state @100 mSec interval
B. Count variable is used for turn on / turn off LED. 3 Times On/Off LED and 250mS off..
'''

from machine import Pin, Timer

#Initialize the onboard LED as ouput
led = Pin(25, Pin.OUT)

#Initialize timer_one. Used for toggeling the LED
timer_one = Timer()

#Initialize count variable. Used for changing the State
count = 1
    
def ChangeState(timer_two):
    global count
    
    if count < 6:
     # Toggle LED
     led.toggle()
     count = count+1
    else:
      # Turn off LED 
      led.off()
      count = count+1
      if count == 30:
       # Reset Count
       count = 1
   
timer_one.init(freq=10, mode=Timer.PERIODIC, callback=ChangeState)
