Pwma Alias Portd.5 ' Modulated Pins
Pwmb Alias Oc1b
' Used Variables
Dim Temp1 As Word
Dim Temp2 As Word
Config Portb = Output ' PortB is Output
Portb = 255 ' Switch LEDs off
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Up
Temp1 = &H0000 ' Configure Timer1 for PWM
Pwm1a = Temp1
Pwm1b = Temp1
Tccr1b = Tccr1b Or &H02 ' Prescaler = 8
Config Pind.0 = Input ' Configure PortD
Config Pind.5 = Output
Do
Bitwait Pind.0 , Reset ' Wait for key pressed
Bitwait Pind.0 , Set ' Wait for key unpressed
Temp1 = Temp1 + &H10 ' Increment Variable
Pwm1a = Temp1 ' Set PWM Registers
Pwm1b = Temp1
Temp2 = Temp1 / &H10 ' Reset 4 LSB and shift right
Temp2 = Not Temp2 ' Invert bit pattern
Portb = Low(temp2) ' Output bit pattern
Loop
End
Lesezeichen