BASCOM LEDs dimmen (PMW)

LED dimmen mit PMW

' LED dimmen mit PWM ' Out: b.1 PWM - Signal an LED ' $regfile = "m8adef.dat" 'Chip: ATmega8 $crystal = 1000000 'Frequenz: 1 MHz $swstack = 50 $hwstack = 50 $framesize = 50 Config Portb.1 = Output Config Timer1 = Pwm , Pwm = 8 , Prescale = 8 , Compare A Pwm = Clear Up Dim A As Byte 'hell: Compare1a = 20 'oder Pwm1a = 20 Wait 2 'dunkler: Pwm1a = 250 Wait 2 Do For A = 255 To 1 Step -10 Compare1a = A Waitms 100 Next A For A = 1 To 255 Step 10 Compare1a = A Waitms 100 Next A Loop End