Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $regfile = "m8def.dat"
- $crystal = 8000000
- $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 = 64
- Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Disconnect
- Config Pind.0 = Output
- Config Debounce = 30
- Debounce Pind.4 , 0 , 0
- Debounce Pind.3 , 0 , 0
- Debounce Pind.2 , 0 , 0
- Debounce Pind.1 , 0 , 0
- Portd.4 = 1 'Start
- Portd.3 = 1 'Mode
- Portd.2 = 1 ' "+"
- Portd.1 = 1 ' "-"
- 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 Dupa As Byte
- Dim Zmiana As Bit
- Dim Timestop As Bit
- Dim Jednostkaczas As Byte
- Dim Liczba As Integer
- Dim Jasnosc As Integer
- Enable Interrupts
- Enable Timer0
- Timer0 = 6
- Licznik = 0
- Sekundy = 55
- Minuty = 1
- Godziny = 0
- Jasnosc = 0
- Jednostkaczas = 0
- Cls
- Cursor Off Noblink
- Jasnosc = 41
- Do
- /////////////////////////////////////// Jasnosc ekranu
- Cls
- Liczba = Getadc(4)
- Liczba = Liczba
- If Liczba > 800 Then
- If Jasnosc < 42 Then
- Jasnosc = Jasnosc + 4
- Waitms 1
- End IF
- If Jasnosc > 42 Then
- Jasnosc = Jasnosc - 4
- Waitms 1
- End If
- End If
- If Liczba < 800 And Liczba > 700 Then
- If Jasnosc < 84 Then
- Jasnosc = Jasnosc + 4
- Waitms 1
- End If
- If Jasnosc > 84 Then
- Jasnosc = Jasnosc - 4
- Waitms 1
- End If
- End If
- If Liczba < 700 And Liczba > 600 Then
- If Jasnosc < 126 Then
- Jasnosc = Jasnosc + 4
- Waitms 1
- End If
- If Jasnosc > 126 Then
- Jasnosc = Jasnosc - 4
- Waitms 1
- End If
- End If
- If Liczba < 600 And Liczba > 500 Then
- If Jasnosc < 168 Then
- Jasnosc = Jasnosc + 4
- Waitms 1
- End If
- If Jasnosc > 168 Then
- Jasnosc = Jasnosc - 4
- Waitms 1
- End If
- End If
- If Liczba < 500 And Liczba > 400 Then
- If Jasnosc < 210 Then
- Jasnosc = Jasnosc + 4
- Waitms 1
- End If
- If Jasnosc > 210 Then
- Jasnosc = Jasnosc - 4
- Waitms 1
- End If
- End If
- If Liczba < 400 Then
- If Jasnosc < 255 Then
- Jasnosc = Jasnosc + 4
- Waitms 1
- End If
- End If
- Pwm1a = Jasnosc
- Lcd Jasnosc
- ////////////////////////////////////////////////// Wyswietlanie czasu
- If Minuty = 0 And Sekundy = 0 Then
- End If
- Timestop = 0
- 'Licznik = 491
- If Licznik > 490 Then
- Cls
- If Sekundy > 9 Then
- Lcd "Time: "
- If Minuty > 9 Then
- Lcd Minuty + ":" + Sekundy
- Else
- Lcd "0" + Minuty + ":" + Sekundy
- End If
- End If
- If Sekundy < 10 Then
- Lcd "Time: "
- If Minuty > 9 Then
- Lcd Minuty + ":" + "0" + Sekundy
- Else
- Lcd "0" + Minuty + ":0" + Sekundy
- End If
- End If
- End If
- If Pind.3 = 0 And Pind.2 = 1 And Pind.1 = 1 Then
- If Jednostkaczas = 2 Then
- Jednostkaczas = 0
- Else
- Jednostkaczas = Jednostkaczas + 1
- End If
- End If
- If Pind.2 = 0 And Pind.1 = 1 And Pind.3 = 1 Then
- If Jednostkaczas = 0 Then
- If Sekundy > 58 Then
- Minuty = Minuty + 1
- Sekundy = 0
- Else
- Sekundy = Sekundy + 1
- End If
- Elseif Jednostkaczas = 1 Then
- Minuty = Minuty + 1
- If Minuty > 58 Then
- Godziny = Godziny + 1
- Minuty = 0
- End If
- Else
- Godziny = Godziny + 1
- End If
- Waitms 200
- End If
- If Timestop = 1 Then
- Waitms 250
- End If
- Loop
- End
- Przerwanie_co_2ms:
- //////////////////////////////// chyba coś tu pierdolili z jasnością też ekranu
- Counter0 = Counter0 + 6
- If Timestop = 0 Then
- Incr Licznik
- If Zmiana = 0 Then
- Pwm1b = Dupa
- Incr Dupa
- If Dupa > 160 Then
- Zmiana = 1
- End If
- Else
- Pwm1b = Dupa
- Decr Dupa
- If Dupa < 1 Then
- Zmiana = 0
- End If
- End If
- ////////////////////////// to chyba jest liczenie czasu
- If Licznik = 500 Then
- Sekundy = Sekundy + 1
- Licznik = 0
- End If
- If Sekundy = 59 Then
- Sekundy = 0
- Minuty = Minuty + 1
- End If
- End If
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement