$regfile = "attiny13.dat" $hwstack = 8 $swstack = 16 $framesize = 16 ' Pin 1 - Reset ' Pin 2 - Output for ADC Out_u ' Pin 3 - Input for ADC (Chanel 2) Input_u ' Pin 4 - Gnd ' Pin 5 - Output for PWM (OC0A) Outpwm ' Pin 6 - Input press key (Int0) Press_key ' Pin 7 - Output for Led low_U Outled ' Pin 8 - U +4.1V Dim I As Byte Dim Pwm As Byte Dim U As Word On Int0 Int0_int Outpwm Alias Portb.0 Press_key Alias Pinb.1 Outled Alias Portb.2 Out_u Alias Portb.3 Ddrb = &B00001101 Config Timer0 = Pwm , Prescale = 8 , Compare A Pwm = Clear Down Start Timer0 Config Adc = Single , Prescaler = Auto , Reference = Internal Enable Interrupts Enable Int0 Config Int0 = Low Level Reset Outled Reset Out_u Pwm = 5 Do Waitms 20 If Pwm = 0 Then Reset Out_u Reset Outled Pwm0a = 0 Powerdown End If If Pwm = 255 Then Pwm = 3 If Pwm = 1 Then Pwm0a = 5 If Pwm = 2 Then Pwm0a = 60 If Pwm = 3 Then Pwm0a = 255 Set Out_u Start Adc U = 0 For I = 0 To 3 Waitms 30 U = U + Getadc(2) Next I Stop Adc Shift U , Right , 2 If U < 512 Then Set Outled Loop End Int0_int: Bitwait Pinb.1 , Set Decr Pwm Waitms 100 Return