No dobra, załączam swoje wypociny (12 lat przerwy w programowaniu.... )
$regfile = "m8535.dat"
$crystal = 16000000
$baud = 9600
Config Portc = Output
Config Pina.2 = Output 'buzer
Config Pina.3 = Output 'katody Diod
Config Pina.4 = Output 'w1
Config Pina.5 = Output 'w2
Config Pina.6 = Output 'w3
Config Pina.7 = Output 'w4
Config Portb = Input ' wejście klawiatury
Set Portb 'pullup rezystory
Config Timer0 = Timer , Prescale = 256
Declare Sub Pobr_znaku(cyfra As Byte)
On Timer0 Mult_wysw
Dim A As Byte , B As Byte , C As Byte
Dim D As Byte , E As Byte , C1 As Byte 'dane do wyświetlenia
Dim F As Byte , O As Byte
Dim G As Bit , H As Bit
Dim S As Bit
Dim Nr_wysw As Byte 'nr zapalonego wyświetlacza
Dim Kr1 As Bit , Kr2 As Bit , Kr3 As Bit
Dim Kr4 As Bit
Dim Wart As Word 'liczba do wyświetlenia
Dim Key As Byte 'zmienna klawiatury
Dim Keytime As Word
Dim Key2 As Bit
Dim Key1 As Byte 'zmienna pomocnicza klawiatury
Dim I As Byte 'zmienna do for
Dim J As Byte 'zmienna do for
Dim Time1 As Word ' s na przerwaniu
Dim Time2 As Word
Dim Time3 As Long ' minuty
Dim Speed1 As Eram Byte
Dim Woda1 As Eram Byte
Dim Woda As Byte 'prędkość
Dim Speed As Byte
Dim Ma As Bit
Dim Wa As Bit
Speed = Speed1
Woda = Woda1
W1 Alias Porta.4
W2 Alias Porta.5
W3 Alias Porta.6
W4 Alias Porta.7
W5 Alias Porta.3
Set Portd.5
Time1 = 0
Time2 = 0
Enable Interrupts
Enable Timer0
Load Timer0 , 20
'program
H = 0
Speed = Speed1
Ma = Woda.1
Wa = Woda.0
Wait 5
E.4 = Woda.1
E.3 = Woda.0
Do
D = 17
F = Speed \ 20
If F = 0 Then C = 20 Else C = F
F = F * 20
F = Speed - F
B = F \ 2
F = Speed Mod 2
A = F * 5
F = Not Key1
If F = 0 Then H = 0
Reset Porta.2
Select Case F
Case 192: '150/300
If H = 0 Then
Set Porta.2
G = Not G
End If
If G = 0 Then Speed = 60 Else Speed = 30
H = 1
Case 128: '+
Set Porta.2
If Key2 = 1 Then Speed = Speed + 4 Else Speed = Speed + 1
If Speed > 180 Then Speed = 180
If H = 1 Then Reset Porta.2
H = 1
Case 64: '-
Set Porta.2
If Key2 = 1 Then Speed = Speed - 4 Else Speed = Speed - 1
If Speed < 10 Then Speed = 10
If H = 1 Thenreset Porta.2
H = 1
Case 32: 'start
If H = 0 Then Set Porta.2
If S = 0 Then S = 1
If Wa = 1 Then Set Portd.6
If Ma = 1 Then Set Portd.5
H = 1
Print "start"
Case 16: 'stop
If H = 0 Then Set Porta.2
S = 0
Reset Portd.6
Reset Portd.5
H = 1
Print "stop"
Case 8: 'woda manual
If H = 0 Then Set Porta.2
Set Portd.6
Do
Loop Until Key1 <> 8
Reset Portd.6
H = 1
Case 4: ' woda auto/mycie
Time3 = 0
Do
Time3 = Time3 + 1
' Toggle E.5
O = Not Pinb
If Time3 > 100000 Then
Ma = Not Ma
E.4 = Ma
Woda.1 = Ma
Set Porta.2
Exit Do
Time3 = 200000
End If
Loop Until O <> 4
If Time3 < 100000 Then
Wa = Not Wa
E.3 = Wa
Woda.0 = Wa
Set Porta.2
End If
Bitwait Pinb.2 , Set
Woda1 = Woda
Wait 1
End Select
'
If Speed <> Speed1 And S = 1 Then Gosub Send
If Speed <> Speed1 Then Speed1 = Speed 'Else
Wait 1
Loop
'koniec programu
Send:
Print Speed
' wysyłanie danych do falownika
Return
Sub Pobr_znaku(cyfra As Byte)
If Cyfra < 17 Then
Portc = Lookup(cyfra , Kody7seg)
Else
Portc = 0
End If
End Sub
Mult_wysw:
'Disable Timer0
Load Timer0 , 8
Set W1
Set W2
Set W3
Set W4
Set W5
Portd = 0
Select Case Nr_wysw
Case 0:
Call Pobr_znaku(a)
Portc.7 = Kr1
Reset W1
Key = Pinb
If Key = 255 Then
Keytime = 0
Key2 = 0
End If
Case 1:
Call Pobr_znaku(b)
Portc.7 = Kr2
Reset W2
Key1 = Key And Pinb
If Key1 = Pinb Then
Keytime = Keytime + 1
End If
If Keytime > 3000 Then Key2 = 1
Case 2:
Call Pobr_znaku(c)
Portc.7 = Kr3
Reset W3
Case 3:
Call Pobr_znaku(d)
Portc.7 = Kr4
Reset W4
Case 4:
Portc = E
Reset W5
End Select
Incr Nr_wysw
If Nr_wysw = 5 Then
Nr_wysw = 0
End If
'liczenie czasu
Incr Time1
If Time1 = 1501 Then
Time1 = 0
Incr Time2
Toggle E.5
End If
'Enable Timer0
Return
Kody7seg:
Data &B00111111 , &B00000110 , &B01011011 , &B01001111 , &B01100110 , &B01101101,
Data &B01111101 , &B00000111 , &B01111111 , &B01101111 , &B01111001 , &B01111000,
Data &B00011100 , &B01100111 , &B00111001 , &B01011100 , &B01011110
Szczęśliwego Nowego Roku!!!