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 = Clear Up
- Deflcdchar 0,32,14,17,17,17,31,4,32' replace [x] with number (0-7)
- Deflcdchar 1,32,14,17,17,17,31,4,32' replace [x] with number (0-7)
- Display On
- On Timer0 Przerwanie_co_2ms
- Dim Licznik As Integer
- Dim Sekundy As Byte
- Dim Minuty As Byte
- Dim Godziny As Byte
- Dim Liczba As Integer
- Dim Jasnosc As Integer
- dim bip as bit
- config portd.3 = input
- config portd.2 = input
- config portd.1 = input
- config portd.0 = input
- config DEBOUNCE = 30
- Deflcdchar 0,32,32,14,21,23,17,14,32' replace [x] with number (0-7)
- Dim godzinaAlarmu as Byte
- Dim minutaAlarmu as Byte
- godzinaAlarmu = 0
- minutaAlarmu = 0
- Dim timeChange as Byte
- timeChange = 0
- 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
- bip = 1
- portc.5 = 0
- Cursor Off Noblink
- Jasnosc = 41
- Do
- '///////////////////////////////////////////////////ustawienia
- IF PinD.2 = 1 THEN
- timeChange = timeChange+1
- IF timeChange > 4 THEN
- timeChange = 0
- END IF
- waitms 500
- END IF
- IF timeChange = 1 THEN
- IF PIND.1 = 1 THEN
- Godziny = Godziny + 1
- IF Godziny = 24 THEN
- Godziny = 0
- ENDIF
- waitms 200
- END IF
- IF PIND.0 = 1 THEN
- Godziny = Godziny - 1
- IF Godziny = 255 THEN
- Godziny = 23
- END IF
- waitms 200
- END IF
- END IF
- IF timeChange = 2 THEN
- IF PIND.1 = 1 THEN
- Minuty =Minuty + 1
- IF Minuty = 60 THEN
- Minuty = 0
- ENDIF
- waitms 200
- END IF
- IF PIND.0 = 1 THEN
- Minuty =Minuty - 1
- IF Minuty = 255 THEN
- Minuty = 59
- END IF
- waitms 200
- END IF
- END IF
- IF timeChange = 3 THEN
- IF PIND.1 = 1 THEN
- godzinaAlarmu = godzinaAlarmu + 1
- IF godzinaAlarmu = 24 THEN
- godzinaAlarmu= 0
- ENDIF
- waitms 200
- END IF
- IF PIND.0 = 1 THEN
- godzinaAlarmu= godzinaAlarmu- 1
- IF godzinaAlarmu = 255 THEN
- godzinaAlarmu= 23
- END IF
- waitms 200
- END IF
- END IF
- IF timeChange = 4 THEN
- IF PIND.1 = 1 THEN
- minutaAlarmu=minutaAlarmu+ 1
- IF Minuty = 60 THEN
- minutaAlarmu= 0
- ENDIF
- waitms 200
- END IF
- IF PIND.0 = 1 THEN
- minutaAlarmu=minutaAlarmu- 1
- IF minutaAlarmu = 255 THEN
- minutaAlarmu= 59
- END IF
- waitms 200
- END IF
- END IF
- '//////////////////////////////////////////////////bip
- IF godzinaAlarmu = godziny AND minutaAlarmu = minuty and bip=1 THEN
- pwm1b=25
- waitms 100
- pwm1b=255
- waitms 100
- IF PIND.3 = 1 THEN
- bip=0
- pwm1b=255
- END IF
- END IF
- if godzinaAlarmu = godziny AND minutaAlarmu <> minuty and bip=0 then
- bip=1
- end if
- '/////////////////////////////////////// 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
- '////////////////////////////////////////////////// Wyswietlanie czasu
- If Licznik > 490 Then
- cls
- upperline
- lcd chr(0)
- 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
- lowerline
- lcd chr(1)
- Lcd " "
- if godzinaAlarmu < 10 then
- lcd "0"
- Lcd Godzinaalarmu
- else
- lcd godzinaalarmu
- end if
- lcd "::"
- if minutaAlarmu <10 then
- lcd "0"
- lcd Minutaalarmu
- else
- lcd minutaalarmu
- 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
- if godziny=24 then
- godziny=0
- end if
- Return
- pip:
- if bip=1 then
- pwm1b=200
- waitms 250
- end if
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement