from __future__ import print_function
import os
from time import sleep
import numpy as np
import pigpio


os.system('sudo pigpiod')
sleep(1)
PWM_freq=20000
PWM_GPIO = 18
pi = pigpio.pi()



if __name__ == "__main__":
 
   #pi.set_mode(PWM_GPIO,pigpio.OUTPUT)

  

   pi.hardware_PWM(PWM_GPIO,PWM_freq,50*10000)
   #pi.set_PWM_frequency(18,8000)

##   for i in range(0,1001,1):
##      pi.hardware_PWM(PWM_GPIO,PWM_freq,1000000*np.sin(np.pi*i/10000.0))
##      #pi.set_PWM_dutycycle(18,255*np.sin(np.pi*i/10000.0))
##      sleep(0.1)	
   print("done")
   
   pi.hardware_PWM(PWM_GPIO,PWM_freq,50*10000)
   #pi.set_mode(PWM_GPIO,pigpio.INPUT)
   pi.stop()



   os.system('sudo killall pigpiod')
   sleep(1)
   print("exit")
   


