Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $regfile = "m8def.dat"
  2. $crystal = 8000000
  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 = 64
  12. Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Disconnect
  13. Config Pind.0 = Output
  14. Config Debounce = 30
  15. Debounce Pind.4 , 0 , 0
  16. Debounce Pind.3 , 0 , 0
  17. Debounce Pind.2 , 0 , 0
  18. Debounce Pind.1 , 0 , 0
  19.  
  20. Portd.4 = 1                                                 'Start
  21. Portd.3 = 1                                                 'Mode
  22. Portd.2 = 1                                                 ' "+"
  23. Portd.1 = 1                                                 ' "-"
  24.  
  25.  
  26. Display On
  27. On Timer0 Przerwanie_co_2ms
  28. Led Alias Portd.0
  29. Dim Licznik As Integer
  30. Dim Sekundy As Byte
  31. Dim Minuty As Byte
  32. Dim Godziny As Byte
  33. Dim Dupa As Byte
  34. Dim Zmiana As Bit
  35. Dim Timestop As Bit
  36. Dim Jednostkaczas As Byte
  37. Dim Liczba As Integer
  38. Dim Jasnosc As Integer
  39.  
  40. Enable Interrupts
  41. Enable Timer0
  42. Timer0 = 6
  43. Licznik = 0
  44.  
  45. Sekundy = 55
  46. Minuty = 1
  47. Godziny = 0
  48.  
  49. Jasnosc = 0
  50.  
  51. Jednostkaczas = 0
  52.  
  53. Cls
  54. Cursor Off Noblink
  55. Jasnosc = 41
  56. Do
  57.  /////////////////////////////////////// Jasnosc ekranu
  58.      Cls
  59.      Liczba = Getadc(4)
  60.      Liczba = Liczba
  61.  
  62.  
  63.      If Liczba > 800 Then
  64.          If Jasnosc < 42 Then
  65.             Jasnosc = Jasnosc + 4
  66.             Waitms 1
  67.          End IF
  68.          If Jasnosc > 42 Then
  69.             Jasnosc = Jasnosc - 4
  70.             Waitms 1
  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.             Waitms 1
  78.          End If
  79.          If Jasnosc > 84 Then
  80.             Jasnosc = Jasnosc - 4
  81.             Waitms 1
  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.             Waitms 1
  89.          End If
  90.          If Jasnosc > 126 Then
  91.             Jasnosc = Jasnosc - 4
  92.             Waitms 1
  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.             Waitms 1
  100.          End If
  101.          If Jasnosc > 168 Then
  102.             Jasnosc = Jasnosc - 4
  103.             Waitms 1
  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.             Waitms 1
  111.          End If
  112.          If Jasnosc > 210 Then
  113.             Jasnosc = Jasnosc - 4
  114.             Waitms 1
  115.          End If
  116.      End If
  117.  
  118.      If Liczba < 400 Then
  119.          If Jasnosc < 255 Then
  120.             Jasnosc = Jasnosc + 4
  121.             Waitms 1
  122.          End If
  123.      End If
  124.  
  125.      Pwm1a = Jasnosc
  126.       Lcd Jasnosc
  127. ////////////////////////////////////////////////// Wyswietlanie czasu
  128.  
  129.  If Minuty = 0 And Sekundy = 0 Then
  130.  
  131.  End If
  132.  
  133.  Timestop = 0
  134.  'Licznik = 491
  135.  
  136.  
  137.  If Licznik > 490 Then
  138.    Cls
  139.    If Sekundy > 9 Then
  140.      Lcd "Time: "
  141.      If Minuty > 9 Then
  142.       Lcd Minuty + ":" + Sekundy
  143.      Else
  144.       Lcd "0" + Minuty + ":" + Sekundy
  145.      End If
  146.    End If
  147.  
  148.  If Sekundy < 10 Then
  149.     Lcd "Time: "
  150.     If Minuty > 9 Then
  151.       Lcd Minuty + ":" + "0" + Sekundy
  152.      Else
  153.       Lcd "0" + Minuty + ":0" + Sekundy
  154.      End If
  155.  End If
  156.  End If
  157.  
  158.  If Pind.3 = 0 And Pind.2 = 1 And Pind.1 = 1 Then
  159.    If Jednostkaczas = 2 Then
  160.       Jednostkaczas = 0
  161.    Else
  162.       Jednostkaczas = Jednostkaczas + 1
  163.    End If
  164.  End If
  165.  
  166.  If Pind.2 = 0 And Pind.1 = 1 And Pind.3 = 1 Then
  167.    If Jednostkaczas = 0 Then
  168.       If Sekundy > 58 Then
  169.         Minuty = Minuty + 1
  170.         Sekundy = 0
  171.       Else
  172.          Sekundy = Sekundy + 1
  173.       End If
  174.  
  175.    Elseif Jednostkaczas = 1 Then
  176.       Minuty = Minuty + 1
  177.  
  178.       If Minuty > 58 Then
  179.          Godziny = Godziny + 1
  180.          Minuty = 0
  181.       End If
  182.  
  183.    Else
  184.       Godziny = Godziny + 1
  185.    End If
  186.  
  187.    Waitms 200
  188.  End If
  189.  
  190.  If Timestop = 1 Then
  191.    Waitms 250
  192.  End If
  193. Loop
  194. End
  195.  
  196.  
  197.  
  198. Przerwanie_co_2ms:
  199. //////////////////////////////// chyba coś tu pierdolili z jasnością też ekranu
  200.  Counter0 = Counter0 + 6
  201.  If Timestop = 0 Then
  202.    Incr Licznik
  203.    If Zmiana = 0 Then
  204.       Pwm1b = Dupa
  205.       Incr Dupa
  206.       If Dupa > 160 Then
  207.          Zmiana = 1
  208.       End If
  209.    Else
  210.       Pwm1b = Dupa
  211.       Decr Dupa
  212.       If Dupa < 1 Then
  213.          Zmiana = 0
  214.       End If
  215.    End If
  216.  
  217. ////////////////////////// to chyba jest liczenie czasu
  218.    If Licznik = 500 Then
  219.       Sekundy = Sekundy + 1
  220.       Licznik = 0
  221.    End If
  222.    If Sekundy = 59 Then
  223.     Sekundy = 0
  224.     Minuty = Minuty + 1
  225.  End If
  226.  End If
  227. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement