'DEVICE 16F628A
Define CONFIG = 0x3f50
AllDigital 'alle ports digital
'port names
Symbol pwm_signaal = PORTA.6 'this port is the PWM signal
Symbol higherkey = PORTB.0 'key to increase
Symbol lowerkey = PORTB.1 'key to decrease
'declaring variable
Dim duty As Byte 'This variable contains the duty (PWM duty value)
'76543210
PORTA = %00000000 'make all the gates of PORTA low
TRISA = %10111111 'PORTA.6 is output for PWM signal
ConfigPin PORTB = Input 'pull-up to activate the buttons
PWMon 1, 10
'mainprogram
main: 'loop
If higherkey = 0 And duty < 250 Then duty = duty + 1 'as on 'Higher Key "is pressed and value is still more, then increase it
If lowerkey = 0 And duty > 0 Then duty = duty - 1 'as on 'Lower Key' is pressed and value is still not zero, then decrease it
PWMduty 1, duty
Goto main
End