Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $regfile = "m8def.dat"
  2. $crystal = 1000000
  3. $hwstack = 40
  4. $swstack = 16
  5. $framesize = 32
  6.  
  7. Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portb.0 , Rs = Portd.7
  8. Config Lcd = 16 * 2
  9. Config Portc.5 = Output
  10. Config Adc = Single , Prescaler = Auto , Reference = Avcc
  11. Config Timer0 = Timer , Prescale = 8
  12. Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Disconnect
  13.  
  14.  
  15.  
  16. Display On
  17. On Timer0 Przerwanie_co_2ms
  18. Led Alias Portd.0
  19. Dim Licznik As Integer
  20. Dim Sekundy As Byte
  21. Dim Minuty As Byte
  22. Dim Godziny As Byte
  23. Dim Liczba As Integer
  24. Dim Jasnosc As Integer
  25. config portd.3 = input
  26. config portd.2 = input
  27. config portd.1 = input
  28. config portd.0 = input
  29. config DEBOUNCE = 30
  30.  
  31. portd.3 = 0
  32. portd.2 = 0
  33. portd.1 = 0
  34. portd.0 = 0
  35.  
  36. Enable Interrupts
  37. Enable Timer0
  38. Enable Timer1
  39. Timer0 = 6
  40.  
  41. Licznik = 0
  42. Sekundy = 0
  43. Minuty = 0
  44. Godziny = 1
  45. Jasnosc = 0
  46.  
  47.  
  48.  portc.5 = 0
  49. Cursor Off Noblink
  50.  
  51. Jasnosc = 41
  52. Do
  53.  
  54. '///////////////////////////////////////////////////CZAS
  55.  
  56.  
  57.  
  58.  '/////////////////////////////////////// Jasnosc ekranu
  59.      Liczba = Getadc(4)
  60.      Liczba = Liczba
  61.  
  62.  
  63.      If Liczba > 800 Then
  64.          If Jasnosc < 42 Then
  65.             Jasnosc = Jasnosc + 4
  66.  
  67.          End IF
  68.          If Jasnosc > 42 Then
  69.             Jasnosc = Jasnosc - 4
  70.  
  71.          End If
  72.      End If
  73.  
  74.      If Liczba < 800 And Liczba > 700 Then
  75.          If Jasnosc < 84 Then
  76.             Jasnosc = Jasnosc + 4
  77.  
  78.          End If
  79.          If Jasnosc > 84 Then
  80.             Jasnosc = Jasnosc - 4
  81.  
  82.          End If
  83.      End If
  84.  
  85.      If Liczba < 700 And Liczba > 600 Then
  86.          If Jasnosc < 126 Then
  87.             Jasnosc = Jasnosc + 4
  88.  
  89.          End If
  90.          If Jasnosc > 126 Then
  91.             Jasnosc = Jasnosc - 4
  92.  
  93.          End If
  94.      End If
  95.  
  96.      If Liczba < 600 And Liczba > 500 Then
  97.          If Jasnosc < 168 Then
  98.             Jasnosc = Jasnosc + 4
  99.  
  100.          End If
  101.          If Jasnosc > 168 Then
  102.             Jasnosc = Jasnosc - 4
  103.  
  104.          End If
  105.      End If
  106.  
  107.      If Liczba < 500 And Liczba > 400 Then
  108.          If Jasnosc < 210 Then
  109.             Jasnosc = Jasnosc + 4
  110.  
  111.          End If
  112.          If Jasnosc > 210 Then
  113.             Jasnosc = Jasnosc - 4
  114.  
  115.          End If
  116.      End If
  117.  
  118.      If Liczba < 400 Then
  119.          If Jasnosc < 250 Then
  120.             Jasnosc = Jasnosc + 4
  121.  
  122.          End If
  123.      End If
  124.  
  125.      Pwm1a = Jasnosc
  126.       'Lcd Jasnosc
  127.  
  128.  
  129.  
  130.  
  131.  
  132.       if pind.0 = 1 then
  133.       pinc.5=1
  134.       godziny = godziny + 1
  135.       if godziny > 23 then
  136.       godziny = 0
  137.       end if
  138.       waitms 500
  139.       end if
  140.       if pind.1 = 1 then
  141.       godziny = godziny -1
  142.       if godziny = 255 then
  143.       godziny = 23
  144.       end if
  145.       waitms 500
  146.  
  147.       end if
  148.       if pind.2 = 1 then
  149.       minuty = minuty+1
  150.       if minuty = 60 then
  151.       minuty = 0
  152.       end if
  153.       waitms 500
  154.  
  155.       end if
  156.       if pind.3 = 1 then
  157.       minuty = minuty -1
  158.       if minuty = 255 then
  159.       minuty = 59
  160.       end if
  161.       waitms 500
  162.  
  163.       end if
  164.  
  165.  
  166. '////////////////////////////////////////////////// Wyswietlanie czasu
  167.  
  168.  
  169.  
  170.  If Licznik > 490 Then
  171.  cls
  172.       Lcd "     "
  173.       if godziny < 10 then
  174.       lcd "0"
  175.       Lcd Godziny
  176.       else
  177.       lcd godziny
  178.       end if
  179.       lcd "::"
  180.       if minuty <10 then
  181.       lcd "0"
  182.       lcd Minuty
  183.       else
  184.       lcd minuty
  185.       end if
  186.  End If
  187.  Waitms 10
  188. Loop
  189. End
  190.  
  191.  
  192.  
  193. Przerwanie_co_2ms:
  194.  
  195.  
  196. '////////////////////////// to chyba jest liczenie czasu
  197.    timer0 = 6
  198.    Incr Licznik
  199.    If Licznik = 500 Then
  200.       Sekundy = Sekundy + 1
  201.       Licznik = 0
  202.    End If
  203.    If Sekundy = 60 Then
  204.     Sekundy = 0
  205.     Minuty = Minuty + 1
  206.  End If
  207.    If Minuty = 60 Then
  208.     Minuty = 0
  209.     Godziny = Godziny + 1
  210.  End If
  211.  
  212. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement