Here's my first code with picbasic pro up and running. It does output variable PWM which I use for led dimming.
Sure, code is written really bad, but, at least it works. I've used included BUTX3 sample as basis:
I believe, first two lines of code are irrelevant for PIC16F628A, but at least it works...Code:CMCON = 7 ' PORTA to digital OPTION_REG = $7f ' Enable PORTB pull-ups TRISB = %11001111 ' Set PORTB.4,5 (LEDs) to output, rest to input A var byte mainloop: PORTB = 0 ' Turn off LEDs ' Check any button pressed to toggle on LED If PORTB.7 = 0 Then ' If 1st button pressed... PORTB.5 = 1 ' Turn on 1st LED A=A+1 if a=255 then a=a-1 HPWM 1,A,1000 Endif If PORTB.6 = 0 Then ' If 2nd button pressed... PORTB.4 = 1 ' Turn on 2nd LED a=A-1 if a=1 then a=a+1 HPWM 1,a,1000 Endif Pause 15 ' Pause 2mS Goto mainloop ' Do it forever End




Bookmarks