logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

[Bascom],[Zegar-Problem z budzikiem]

adi84_84 03 Cze 2010 15:47 1736 1
REKLAMA
  • #1 8150583
    adi84_84
    Poziom 14  
    Witam wszystkich.Zacząłem naukę programowania (Bascom),więc proszę o wyrozumiałość. Napisałem taki program zegara RTC z kwarcem 32768Hz i nie wiem jak dopisać mam guziki do ustawiania budzika.Siedzę dwa dni i nic mi nie wychodzi.Polski help i książka Marcina Wiązani w tym przypadku jakoś mi nie pomaga.Oto kod źródłowy:

                                $regfile = "m8def.dat"
    
    $crystal = 8000000 .
    Config Lcd = 16 * 2
    Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5
    Config Clock = Soft
    Config Date = Dmy , Separator = /
    
     '..............................................................................
    
    Config Pind.0 = Input                                       'Ustaw godzinę.
    Portd.0 = 1
    Config Pind.1 = Input                                       'Ustaw minuty.
    Portd.1 = 1
    Config Pind.2 = Input                                       'Ustaw rok.
    Portd.2 = 1
    Config Pind.3 = Input                                       'Ustaw miesiąc.
    Portd.3 = 1
    Config Pind.4 = Input                                       'Ustaw dzień.
    Portd.4 = 1
    Config Pinb.0 = Input                                       'Powrót do zegara.
    Portb.0 = 1
    Config Pind.7 = Output                                      'Głośnik.
    Portd.7 = 1
    
     '..............................................................................
    
    Enable Interrupts
    Date$ = "00/00/00"
    Time$ = "00:00:00"
    
     '..............................................................................
    
    Zegar:
    Do
    Waitms 100
    Cls
    If Pind.0 = 0 Then
    Waitms 25
    If Pind.0 = 0 Then
    Incr _hour
    If _hour = 24 Then
    _hour = 0
    End If
    End If
    End If
    
    If Pind.1 = 0 Then
    Waitms 25
    If Pind.1 = 0 Then
    Incr _min
    If _min = 60 Then
    _min = 0
    End If
    End If
    End If
    
    If Pind.2 = 0 Then
    Waitms 25
    If Pind.2 = 0 Then
    Incr _year
    If _year = 50 Then
    _year = 0
    End If
    End If
    End If
    
    If Pind.3 = 0 Then
    Waitms 25
    If Pind.3 = 0 Then
    Incr _month
    If _month = 13 Then
    _month = 0
    End If
    End If
    End If
    
    If Pind.4 = 0 Then
    Waitms 25
    If Pind.4 = 0 Then
    Incr _day
    If _day = 32 Then
    _day = 0
    End If
    End If
    End If
    
    
    
    'BUDZIK ??? Nie wiem jak przypisać guziki do jego ustawiania...................
    
    
    
    If _hour = 00 Then
    If _min = 00 Then
    If _sec = 05 Then
    Gosub Budzik
    End If
    End If
    End If
    
     '..............................................................................
    
    
    Lcd Time$
    Locate 1 , 10
    Lcd "Czas"
    Lowerline
    Lcd Date$
    Locate 2 , 10 .
    Lcd "Data"
    Loop
    
     '..............................................................................
    
     Budzik:
    Do
    Cls
    Lcd "Budzik"
    Sound Portd.7 , 300 , 600
    If Pinb.0 = 0 Then
    Waitms 25
    If Pinb.0 = 0 Then
    Gosub Zegar
    End If
    End If
    Loop
    End
  • REKLAMA
  • #2 8150600
    marco47
    Poziom 41  
    Zaznacz cały kod i naciśnij przycisk Code, bo tak to ciężko coś przeczytać i pousuwaj wolne linie między liniami kodu. Będzie bardziej czytelny.
REKLAMA