$regfile = "attiny45.dat" $crystal = 1000000 Led Alias Portb.3 Ssr Alias Portb.4 Config Portb = Output Dim I As Byte Dim Eep As Byte Dim Temp As Byte Temp = 255 Gosub Geteepromstatus 'wenn eine 1 ausgelesen wurde, schalten wir das Licht an If Eep = 1 Then Gosub Ledblink Ssr = 1 End If If Eep = 0 Then Led = 1 Powerdown End Geteepromstatus: 'at first we read the value from eeprom. As we dont know where it is, we must search 'for it. I = 0 Do Incr I Readeeprom Eep , I Loop Until Eep <> 255 Or I = 255 'if the device is new, there will be no value in eeprom so we have to make some preset If I = 255 Then I = 1 Eep = 0 End If 'delete the old value from eeprom Writeeeprom Temp , I 'for the next time, we must change the eeprom value of course... If Eep = 0 Then Eep = 1 Else Eep = 0 End If 'go to next eeprom position, if we are at end, we will go to pos 1 If I = 254 Then I = 1 Else Incr I End If 'now write the value to the new position Writeeeprom Eep , I Return Ledblink: For I = 1 To 14 Led = 1 Waitms 35 Led = 0 Waitms 250 Next Return