$crystal = 8000000 Config Portb = Output Config Pind.3 = Input Config Pind.2 = Input 'Taste Portd.2 = 1 'Pullup Dim Count As Integer Dim Power_state As Bit Power_state = 0 Config Timer1 = Timer , Prescale = 256 'Timer1 als Timer initialisieren Enable Interrupts Enable Int0 Portb = &B11111111 On Int0 Power_on Config Powermode = Powerdown Do Count = 0 While Pind.3 = 0 'Warten auf Impuls If Pind.2 = 0 Then 'Taste schaltet Gerät aus (Powermode = Powerdown) Portb = &B11111111 While Pind.2 = 0 Wend Waitms 100 'Taste entprellen Enable Int0 Config Powermode = Powerdown End If Wend Timer1 = 0 'Timer auf "0" While Pind.3 = 1 'Warten auf Ende des Impulses Wend Count = Timer1 'Stand des Timers auslesen If Count > 1600 Then 'Timer auswerten und die passenden Segmente einschalten Portb = &B11110111 '- Elseif Count > 1425 Then Portb = &B00011000 '0 Elseif Count > 1275 Then Portb = &B10010000 '9 Elseif Count > 1125 Then Portb = &B00010000 '8 Elseif Count > 975 Then Portb = &B11011100 '7 Elseif Count > 825 Then Portb = &B00010001 '6 Elseif Count > 675 Then Portb = &B10010001 '5 Elseif Count > 525 Then Portb = &B11010010 '4 Elseif Count > 375 Then Portb = &B10010100 '3 Elseif Count > 225 Then Portb = &B00110100 '2 Elseif Count > 100 Then Portb = &B11011110 '1 End If Loop Power_on: 'Taste schaltet Gerät ein (IRQ0) Disable Int0 Portb = &B11110111 While Pind.2 = 0 Wend Waitms 100 'Taste entprellen Return