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-nie moge sobie poradzić z programem, nikt nie pomoże?

dark_ghost 14 Lip 2010 13:40 1316 6
REKLAMA
  • #1 8290996
    dark_ghost
    Poziom 10  
    Witam mam pytanko odnośnie programu. Chcę żeby po podaniu masy na PINC.1 na PINA.1 pojawiło się napięcie i zniknęło. ale tylko raz aż do odłączenia masy od PINC.1 co natomiast spowodować ma pojawienie się i zniknięcie napięcia na PINA.2 ale nie może sie to dziać co obrót pętli tylko raz po każdej zmianie stanu na PINC.1

    Proszę poprawić tytuł wiadomości na coś mówiący o problemie.
    Robak
  • REKLAMA
  • #2 8292394
    arktik1
    Poziom 27  
    "Chcę żeby po podaniu masy na PINC.1 na PINA.1 pojawiło się napięcie i zniknęło."
    Przecież to zwarcie.
    Nie rozumiem?
  • REKLAMA
  • #3 8292427
    Krauser
    Poziom 26  
    
    config portc = input                          
    portc = &B00000010 
    config porta = output    
    
    do
    Debounce Pinc.1 , 0 , mignijA1, Sub
    Debounce Pinc.1 , 1 , mignijA2 , Sub
    
    loop
    end
    
    mignijA1:
    porta.1 = 1
    waitms 1000
    porta.1 = 0
    return
    
    mignijA2:
    porta.2 = 1
    waitms 1000
    porta.2 = 0
    return
    
  • REKLAMA
  • #4 8292795
    arktik1
    Poziom 27  
    Sorki źle zrozumiałem.
    Można też zrobić tak:
    
    Dim Q As Byte
    Config Porta = Output
            Porta = &B00000000
    Config Portc = Input
            Portc = &B11111111
    
    Do
    
    Debounce Pinc.1 , 0 , Mig1 , Sub
    Debounce Pinc.1 , 1 , Mig2 , Sub
    Loop
    End
    
    
    Mig1:
    Q = 0
    Do
    If Q = 0 Then
    Porta.1 = 1
    Wait 1
    Porta.1 = 0
    Q = 1
    End If
    If Pinc.1 = 1 Then
    Q = 0
    Return
    End If
    Loop
    
    Mig2:
    Q = 0
    Do
    If Q = 0 Then
    Porta.2 = 1
    Wait 1
    Porta.2 = 0
    Q = 1
    End If
    If Pinc.1 = 0 Then
    Q = 0
    Return
    End If
    Loop
    
  • REKLAMA
  • #5 8292950
    dark_ghost
    Poziom 10  
    W zasadzie Twój kod działa ale nie bardzo wiem jak go zastosować :(
    To mój program

    $regfile = "m32def.dat"
    $crystal = 8000000
    
    
    $baud = 19200
    Config Serialin = Buffered , Size = 200
    
    
    
    Dim Kod As Byte
    Dim Bufor As Byte
    Dim R As Byte
    Dim Q As Byte
    
    Config Portc = Input
    Portc = &HFF
    Config Porta = Output
    Porta = &B00000000
    
    
    Do
    
    If Pinc.1 = 0 Then                                          'uzbrojenie
    Porta.0 = 1
    
    
    Debounce Pinc.1 , 0 , Mig1 , Sub
    Debounce Pinc.1 , 1 , Mig2 , Sub
    
    
    If Pinc.0 = 0 Then                                          'syrena
    Wait 3
    If Pinc.0 = 0 Then
    
    
    
    If Pinc.7 = 0 Then
    Print "ATE0" ; Chr(13)
    Waitms 100
    Print "ATDnumertelefonu1;" ; Chr(13)                             'pierwszy numer
    
    For R = 0 To 100
    
    Porta.0 = 0
    Waitms 200
    Porta.0 = 1
    Waitms 200
    Next R
    
    Print "ATH" ; Chr(13)
        End If
    
    
    
    
    
    
    If Pinc.6 = 0 Then
    Print "ATE0" ; Chr(13)
    Waitms 100
    Print "ATDnumertelefonu2;" ; Chr(13)                             'drogi numer
    
    For R = 0 To 50
    
    Porta.0 = 0
    Waitms 200
    Porta.0 = 1
    Waitms 200
    Next R
    
    Print "ATH" ; Chr(13)
        End If
    
    
    For R = 0 To 40
    
    Porta.0 = 0
    Wait 1
    Porta.0 = 1
    Wait 1
    Next R
    Gosub Oproznij_bufor
      Porta.0 = 0
        End If
      End If
       Else
        End If
    
        Porta.0 = 0
    
    Loop
    End
    
    
    
    Oproznij_bufor:                                             'Opróżnia bufor z odpowiedzi telefonu
    
       Do
          Kod = Inkey()
          Bufor = Ischarwaiting()
       Loop Until Bufor = 0
    
    
    
    Mig1:
    Q = 0
    Do
    If Q = 0 Then
    Porta.1 = 1
    Wait 1
    Porta.1 = 0
    Q = 1
    End If
    If Pinc.1 = 1 Then
    Q = 0
    Return
    End If
    Loop
    
    Mig2:
    Q = 0
    Do
    If Q = 0 Then
    Porta.2 = 1
    Wait 1
    Porta.2 = 0
    Q = 1
    End If
    If Pinc.1 = 0 Then
    Q = 0
    Return
    End If
    Loop


    Dodałem to i działa ale tylko w połowie. Nie zawsze przy odłączeniu od pinc.1 masy zapala sie dioda na pina.2
    
    
    
    Mig1:
    Q = 0
    Do
    If Q = 0 Then
    Porta.1 = 1
    Wait 1
    Porta.1 = 0
    Q = 1
    End If
    If Pinc.1 = 1 Then
    Q = 0
    Return
    End If
    If Pinc.0 = 0 Then
    Q = 0
    Return
    End If
    Loop
    
    Mig2:
    Q = 0
    Do
    If Q = 0 Then
    Porta.2 = 1
    Wait 1
    Porta.2 = 0
    Q = 1
    End If
    If Pinc.1 = 0 Then
    Q = 0
    Return
    End If
    If Pinc.0 = 0 Then
    Q = 0
    Return
    End If
    Loop
    
  • #6 8293831
    arktik1
    Poziom 27  
    Po co dodałeś to:
    
    If Pinc.0 = 0 Then
    Q = 0
    Return
    End If
    Loop
    

    Program miał działać z miganiem diody, nie mówiłeś nic o właściwym programie.
  • #7 8293954
    dark_ghost
    Poziom 10  
    Wiem dlatego podałem reszte bo zrozumiałem że bez niej jest ciężko.
REKLAMA