$regfile = "attiny13.dat"                                   'or Tiny45
$crystal = 1000000                                          '1 MHz
$hwstack = 10
$swstack = 10
$framesize = 20

'Ein- und Ausgaenge definieren / In and Output Config
' 0 = Eingang, 1 = Ausgang  / 0 = in, 1 = out

Ddrb.0 = 0                                                  'Taster / groper
Portb.0 = 1
                                              'Pull-Up R
Taster Alias Pinb.0

'Ausg寧e-----------------------------------------------------------------


Ddrb.1 = 1                                                  'output LED
Ddrb.3 = 1                                                  'output Reset-release
Portb.3 = 0                                                 'Port off

Ocr0b = 0
Tccr0a = &B00100011                                         'PWM-Config
Tccr0b = &B00000001                                         'too
Ocr0b = 0                                                   'LED off

Mcucr = &B00110000                                          'Sleep Mode config
'Prr = &B00000011                                            'other consumer off

Dim Led As Byte                                             'Var for LED- brightness
Dim Led_dimm As Byte                                        'Var for LED brightness turn ON


'                       |----------------------------|
'-----------------------| Here the master programm   |-------------------------
'                       |----------------------------|
Waitms 300                                                  'groper debounce.
Led = 1                                                     ' brightness value 1
'Disable Int0

For Led_dimm = 0 To 50 Step 1                               'if turn on, dim mode 1
Ocr0b = Led_dimm
Waitms 20
Next Led_dimm

' Here the Do / Loop  --------------------------------------------
Do
Main:


If Taster = 0 Then                                          'if groper down, next dim level
Led = Led + 1                                               'Level 1 to 4
Waitms 500
Else
End If

If Led = 5 Then Led = 0                                     'reset var if level 5

     '                                        config the brightness values
If Led = 1 Then Ocr0b = 50                                  'low
If Led = 2 Then Ocr0b = 120                                 'mid
If Led = 3 Then Ocr0b = 255                                 'high

If Led = 4 Then                                             'if grouper 4 times pushed,
Led = 0                                                     'go to sleep mode with
                                             '500nA current consumption !!
For Led_dimm = 255 To 0 Step -2
              'if sleep mode activ, dim down
Ocr0b = Led_dimm
Waitms 2
Next Led_dimm

Ocr0b = 0
Portb.3 = 1
Waitms 20

!sleep                                                      'Sleep Modus, wake up with transistor
Else
End If

Goto Main
Loop

'===========================================================================


End                                                         'end program