Or You can try something like this :
Code:@ device pic12F683, XT_OSC, wdt_off, pwrt_on, mclr_off, protect_off, bod_off DEFINE OSC 4 INCLUDE "MODEDEFS.BAS" GPIO = %00111011 TRISIO = %00111011 ' ATTENTION !!! CCP1CON = %00001100 ' Mode select = PWM T2CON = %00000100 ' Timer2 ON + 1:1 prescale PR2 = %00011001 ' Set PWM frequency to 39kHz ANSEL = %00000000 CMCON0 = %00000111 but1 var GPIO.0 ; gpio.2 is CCPR1L CCPR1L = 0 i var byte '========================================= main: pause 100 if but1=1 then do_command do_command: CCPR1L=8 pauseus 1300 CCPR1L=0 pauseus 300 for i=1 to 7 CCPR1L=8 pauseus 100 CCPR1L=0 pauseus 100 next i PAUSE 500 Goto Main




Bookmarks