Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $regfile = "m8def.dat"
- $crystal = 1000000
- $hwstack = 40
- $swstack = 16
- $framesize = 32
- Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portb.0 , Rs = Portd.7
- Config Lcd = 16 * 2
- Config Portc.5 = Output
- Config Adc = Single , Prescaler = Auto , Reference = Avcc
- Config Timer0 = Timer , Prescale = 8
- Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Disconnect
- Display On
- On Timer0 Przerwanie_co_2ms
- Led Alias Portd.0
- Dim Licznik As Integer
- Dim Sekundy As Byte
- Dim Minuty As Byte
- Dim Godziny As Byte
- Dim Liczba As Integer
- Dim Jasnosc As Integer
- config portd.3 = input
- config portd.2 = input
- config portd.1 = input
- config portd.0 = input
- config DEBOUNCE = 30
- portd.3 = 0
- portd.2 = 0
- portd.1 = 0
- portd.0 = 0
- Enable Interrupts
- Enable Timer0
- Enable Timer1
- Timer0 = 6
- Licznik = 0
- Sekundy = 0
- Minuty = 0
- Godziny = 1
- Jasnosc = 0
- portc.5 = 0
- Cursor Off Noblink
- Jasnosc = 41
- Do
- '///////////////////////////////////////////////////CZAS
- '/////////////////////////////////////// Jasnosc ekranu
- Liczba = Getadc(4)
- Liczba = Liczba
- If Liczba > 800 Then
- If Jasnosc < 42 Then
- Jasnosc = Jasnosc + 4
- End IF
- If Jasnosc > 42 Then
- Jasnosc = Jasnosc - 4
- End If
- End If
- If Liczba < 800 And Liczba > 700 Then
- If Jasnosc < 84 Then
- Jasnosc = Jasnosc + 4
- End If
- If Jasnosc > 84 Then
- Jasnosc = Jasnosc - 4
- End If
- End If
- If Liczba < 700 And Liczba > 600 Then
- If Jasnosc < 126 Then
- Jasnosc = Jasnosc + 4
- End If
- If Jasnosc > 126 Then
- Jasnosc = Jasnosc - 4
- End If
- End If
- If Liczba < 600 And Liczba > 500 Then
- If Jasnosc < 168 Then
- Jasnosc = Jasnosc + 4
- End If
- If Jasnosc > 168 Then
- Jasnosc = Jasnosc - 4
- End If
- End If
- If Liczba < 500 And Liczba > 400 Then
- If Jasnosc < 210 Then
- Jasnosc = Jasnosc + 4
- End If
- If Jasnosc > 210 Then
- Jasnosc = Jasnosc - 4
- End If
- End If
- If Liczba < 400 Then
- If Jasnosc < 250 Then
- Jasnosc = Jasnosc + 4
- End If
- End If
- Pwm1a = Jasnosc
- 'Lcd Jasnosc
- if pind.0 = 1 then
- pinc.5=1
- godziny = godziny + 1
- if godziny > 23 then
- godziny = 0
- end if
- waitms 500
- end if
- if pind.1 = 1 then
- godziny = godziny -1
- if godziny = 255 then
- godziny = 23
- end if
- waitms 500
- end if
- if pind.2 = 1 then
- minuty = minuty+1
- if minuty = 60 then
- minuty = 0
- end if
- waitms 500
- end if
- if pind.3 = 1 then
- minuty = minuty -1
- if minuty = 255 then
- minuty = 59
- end if
- waitms 500
- end if
- '////////////////////////////////////////////////// Wyswietlanie czasu
- If Licznik > 490 Then
- cls
- Lcd " "
- if godziny < 10 then
- lcd "0"
- Lcd Godziny
- else
- lcd godziny
- end if
- lcd "::"
- if minuty <10 then
- lcd "0"
- lcd Minuty
- else
- lcd minuty
- end if
- End If
- Waitms 10
- Loop
- End
- Przerwanie_co_2ms:
- '////////////////////////// to chyba jest liczenie czasu
- timer0 = 6
- Incr Licznik
- If Licznik = 500 Then
- Sekundy = Sekundy + 1
- Licznik = 0
- End If
- If Sekundy = 60 Then
- Sekundy = 0
- Minuty = Minuty + 1
- End If
- If Minuty = 60 Then
- Minuty = 0
- Godziny = Godziny + 1
- End If
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement