@ stromflo... code is der hier:
Code:
$regfile = "m8def.dat"
$crystal = 8000000
'-----LCD-----
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.5 , Rs = Portc.4
Dim X As Word
Dim Y As Word
Dim Tag As Byte
Dim Sekunde As Byte
Dim Minute As Byte
Dim Stunde As Byte
Dim Minute_weck As Byte
Dim Stunde_weck As Byte
Dim Sekunde_weck As Byte
Dim Minute_schlummer As Byte
Dim Stunde_schlummer As Byte
Dim Sekunde_schlummer As Byte
Dim Beleuchtung_an As Byte
Dim Wecker_an As Bit
Dim Schlummer As Bit
Dim Schnarch As Byte
Dim Zaehler As Byte
Dim Klingeln As Bit
Dim Dummy As Byte
Dim Dummy2 As Bit
Dim Ton As Byte
Dim Ton_l As Byte
'-----Timer-----
Config Timer1 = Timer , Prescale = 256 'Konfiguriere Timer1
Enable Timer1 'schalte den Timer1 ein
On Timer1 Isr_von_timer1 'verzweige bei Timer1 überlauf zu Isr_von_Timer1
Timer1 = 34285 'Timer1 soll schon von 34285 wegzählen
'Timer1 soll schon von 34285 wegzählen
Enable Interrupts
'---Subs------
Declare Sub Zeit_einstellen
Declare Sub Wecken
Declare Sub Zeile_1
Declare Sub Zeile_2
Declare Sub Beleuchtung
Declare Sub Weck_an_aus
Declare Sub Weckzeit_einstellen
Declare Sub Schlummer
'----Ports----
Config Pinb.2 = Output
Config Pind.1 = Output
Config Pind.6 = Output
Config Pind.7 = Output
Config Pind.4 = Output
Config Pind.5 = Output
Config Pind.0 = Input
Config Pinb.3 = Input
Config Pinb.0 = Input
Config Pinb.5 = Input
Led1 Alias Portd.1
Led2 Alias Portd.6
Led3 Alias Portd.7
Led4 Alias Portd.4
Beeper Alias Portd.5
Beleucht Alias Portb.2
Taster_plus Alias Pind.0
Taster_minus Alias Pinb.3
Taster_enter Alias Pinb.0
Taster_schlummer Alias Pinb.5
Portd.0 = 1
Portb.3 = 1
Portb.0 = 1
Portb.5 = 1
Cls
Cursor Off
Locate 1 , 1
Lcd "Hallo ich bin"
Locate 2 , 1
Lcd "ein Wecker...."
'--------------Programm------------------------------------------------
Beleucht = 1
Wait 1
Tag = 0
Stunde = 0
Minute = 0
Minute_weck = 0
Stunde_weck = 0
Wecker_an = 0
Schlummer = 0
Zaehler = 0
Beleuchtung_an = 0
Klingeln = 0
Schlummer = 0
Zeit_einstellen
Beleucht = 0
Do
Wecken
Weck_an_aus
Weckzeit_einstellen
Beleuchtung
Zeile_2
Zeile_1
Schlummer
Waitms 10
Led1 = 0
Led2 = 0
Led3 = 0
Led4 = 0
Loop
'-----------------SUBS-------------------------------------------------
'-------------Wecken
Sub Wecken
If Wecker_an = 1 Then
If Stunde = Stunde_schlummer Then
If Minute = Minute_schlummer Then
If Sekunde = Sekunde_schlummer Then
Klingeln = 1
Beleucht = 1
End If
End If
End If
If Klingeln = 1 Then
Ton = Rnd(12)
Ton = Rnd(32)
Ton = Ton / 4
Ton_l = 100 / Ton
For X = 1 To Ton_l
Beeper = 1
Waitms Ton
Beeper = 0
Next X
Select Case Ton
Case 1
Led1 = 0
Led2 = 1
Led3 = 0
Led4 = 1
Case 2
Led1 = 1
Led2 = 0
Led3 = 0
Led4 = 1
Case 3
Led1 = 1
Led2 = 0
Led3 = 1
Led4 = 0
Case 4
Led1 = 0
Led2 = 1
Led3 = 1
Led4 = 0
Case 5
Led1 = 1
Led2 = 1
Led3 = 0
Led4 = 0
Case 5
Led1 = 0
Led2 = 0
Led3 = 1
Led4 = 1
Case 5
Led1 = 1
Led2 = 1
Led3 = 1
Led4 = 1
Case 5
Led1 = 0
Led2 = 0
Led3 = 0
Led4 = 1
End Select
End If
Else
Led1 = 0
Led2 = 0
Led3 = 0
Led4 = 0
End If
End Sub
'------------- Zeit einstellen-------------------------
Sub Zeit_einstellen
While Zaehler < 4
Zeile_1
Locate 2 , 1
Select Case Zaehler
Case 0
Lcd "Wochentag " ' anzeigen der eingabe auf 2. spalte
Case 1
Lcd "Stunde "
Case 2
Lcd "Minute "
Case 3
Lcd "Sekunde "
End Select
Waitms 200
' Zeit einstellen
If Taster_plus = 0 Then
Select Case Zaehler
Case 0
Incr Tag
Case 1
Incr Stunde
Case 2
Incr Minute
Case 3
Incr Sekunde
End Select
End If
If Taster_minus = 0 Then
Select Case Zaehler
Case 0
Decr Tag
Case 1
Decr Stunde
Case 2
Decr Minute
Case 3
Decr Sekunde
End Select
End If
If Taster_enter = 0 Then
Incr Zaehler
End If
If Tag = 7 Then
Tag = 0
End If
If Tag > 250 Then
Tag = 23
End If
If Stunde = 24 Then
Stunde = 0
End If
If Stunde > 250 Then
Stunde = 23
End If
If Minute = 60 Then
Minute = 0
End If
If Minute > 250 Then
Minute = 59
End If
If Sekunde = 60 Then
Sekunde = 0
End If
If Sekunde > 250 Then
Sekunde = 59
End If
Wend
End Sub
'----------Weckzeit-einstellen
Sub Weckzeit_einstellen
If Taster_enter = 0 Then
If Dummy > 30 Then
Zaehler = 0
Led1 = 1
Led2 = 1
Led3 = 1
Led4 = 1
Waitms 100
Led1 = 0
Led2 = 0
Led3 = 0
Led4 = 0
Locate 1 , 1
Lcd "Weck-Stunde "
Waitms 500
While Zaehler < 3
Zeile_2
Locate 1 , 1
Select Case Zaehler ' anzeigen der eingabe auf 2. spalte
Case 0
Lcd "Weck-Stunde "
Case 1
Lcd "Weck-Minute "
Case 2
Lcd "Weck-Sekunde :) "
End Select
Waitms 300
' Zeit einstellen
If Taster_plus = 0 Then
Select Case Zaehler
Case 0
Incr Stunde_weck
Case 1
Incr Minute_weck
Case 2
Incr Sekunde_weck
End Select
End If
If Taster_minus = 0 Then
Select Case Zaehler
Case 0
Decr Stunde_weck
Case 1
Decr Minute_weck
Case 2
Decr Sekunde_weck
End Select
End If
If Taster_enter = 0 Then
Incr Zaehler
End If
If Stunde_weck = 24 Then
Stunde_weck = 0
End If
If Stunde_weck > 250 Then
Stunde_weck = 23
End If
If Minute_weck = 60 Then
Minute_weck = 0
End If
If Minute_weck > 250 Then
Minute_weck = 59
End If
If Sekunde_weck = 60 Then
Sekunde_weck = 0
End If
If Sekunde_weck > 250 Then
Sekunde_weck = 59
End If
If Sekunde = 60 Then
Sekunde = 0
Incr Minute
End If
If Minute = 60 Then
Minute = 0
Incr Stunde
End If
If Stunde = 24 Then
Stunde = 0
Incr Tag
End If
If Tag = 7 Then
Tag = 0
End If
Wend
Dummy = 0
Dummy2 = 0
Stunde_schlummer = Stunde_weck
Minute_schlummer = Minute_weck
Sekunde_schlummer = Sekunde_weck
Wecker_an = 1
End If
End If
End Sub
'---------- Zeile 1 Schreibe
Sub Zeile_1
If Sekunde = 60 Then
Sekunde = 0
Incr Minute
End If
If Minute = 60 Then
Minute = 0
Incr Stunde
End If
If Stunde = 24 Then
Stunde = 0
Incr Tag
End If
If Tag = 7 Then
Tag = 0
End If
Locate 1 , 1
Select Case Tag
Case 0
Lcd "MO "
Case 1
Lcd "DI "
Case 2
Lcd "MI "
Case 3
Lcd "DO "
Case 4
Lcd "FR "
Case 5
Lcd "SA "
Case 6
Lcd "SO "
End Select
' Zeitzeile setzen
If Stunde < 10 Then
Locate 1 , 4
Lcd "0" ; Stunde ; ":"
Else
Locate 1 , 4
Lcd Stunde ; ":"
End If
If Minute < 10 Then
Locate 1 , 7
Lcd "0" ; Minute ; ":"
Else
Locate 1 , 7
Lcd Minute ; ":"
End If
If Sekunde < 10 Then
Locate 1 , 10
Lcd "0" ; Sekunde ; " Uhr "
Else
Locate 1 , 10
Lcd Sekunde ; " Uhr"
End If
End Sub
'---------- Zeile 2 Schreibe
Sub Zeile_2
Locate 2 , 1
Lcd " "
If Stunde_weck < 10 Then
Locate 2 , 4
Lcd "0" ; Stunde_weck ; ":"
Else
Locate 2 , 4
Lcd Stunde_weck ; ":"
End If
If Minute_weck < 10 Then
Locate 2 , 7
Lcd "0" ; Minute_weck ; ":"
Else
Locate 2 , 7
Lcd Minute_weck ; ":"
End If
If Sekunde_weck < 10 Then
Locate 2 , 10
Lcd "0" ; Sekunde_weck
Else
Locate 2 , 10
Lcd Sekunde_weck
End If
If Wecker_an = 1 Then
Locate 2 , 12
Lcd " an "
Else
Locate 2 , 12
Lcd " aus"
End If
Locate 2 , 12
If Schlummer = 1 Then
If Schnarch < 10 Then
Lcd " Zzz"
Elseif Schnarch < 20 Then
If Schnarch > 10 Then
Lcd " zZz"
End If
Elseif Schnarch < 30 Then
If Schnarch > 20 Then
Lcd " zzZ"
End If
Elseif Schnarch < 40 Then
If Schnarch > 30 Then
Lcd " zzz"
End If
End If
Incr Schnarch
If Schnarch = 40 Then
Schnarch = 1
End If
End If
End Sub
'---------AN-AUS--------------------
Sub Weck_an_aus
If Taster_enter = 1 Then
Dummy = 0
Dummy2 = 0
Else
Waitms 10
Incr Dummy
End If
If Taster_enter = 0 Then
If Dummy > 10 Then
If Dummy2 = 0 Then
Led1 = 1
Led2 = 1
Led3 = 1
Led4 = 1
Waitms 100
Klingeln = 0
Dummy2 = 1
If Wecker_an = 1 Then
Wecker_an = 0
Schlummer = 0
Else
Wecker_an = 1
Stunde_schlummer = Stunde_weck
Minute_schlummer = Minute_weck
Sekunde_schlummer = Sekunde_weck
End If
End If
Led1 = 0
Led2 = 0
Led3 = 0
Led4 = 0
End If
End If
End Sub
'-----------Schlummer---------------
Sub Schlummer
If Taster_schlummer = 0 Then
If Klingeln = 1 Then
Klingeln = 0
Schlummer = 1
For X = 1 To 5
Incr Minute_schlummer
If Minute_schlummer = 60 Then
Minute_schlummer = 0
Incr Stunde_schlummer
End If
If Stunde_schlummer = 24 Then
Stunde_schlummer = 0
End If
Next X
End If
End If
End Sub
'-----------Beleuchtung-------------
Sub Beleuchtung
If Taster_plus = 0 Then
Beleuchtung_an = 15
End If
If Taster_minus = 0 Then
Beleuchtung_an = 15
End If
If Taster_enter = 0 Then
Beleuchtung_an = 15
End If
If Taster_schlummer = 0 Then
Beleuchtung_an = 15
End If
If Beleuchtung_an > 0 Then
Beleucht = 1
Else
Beleucht = 0
End If
End Sub
'--------------TIMER----------------
'-------Timer1
Isr_von_timer1: 'ISR von Timer1
Timer1 = 34285 'Timer1 soll wieder von 34285 wegzählen
Incr Sekunde
If Beleuchtung_an > 0 Then
Decr Beleuchtung_an
End If
Return
ausserdem hat sich meine freundin auch noch einen wecker gebaut... der sieht jetzt so aus:
Bild hier
Bild hier
kann das gleiche... ist nur ein bischen lauter, hat ne platine statt nem drahtnetz und wohnt in einer alten kaffedose
Lesezeichen