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