'Sparrow_Morsen_Sputnik.bas
$regfile = "attiny13.dat"
$crystal = 9600000
$hwstack = 8
$swstack = 4
$framesize = 4
Led1 Alias Portb.1
Led2 Alias Portb.3
S1 Alias Pinb.0
S2 Alias Pinb.2
Config Portb = &B000011010
Dim D As Byte
Dim T As Byte
Dim B As Byte
Dim C As Byte
Dim N As Byte
Dim M As Byte
Dim I As Byte
Dim J As Byte
Clkpr = 128 '9,6 MHz
Clkpr = 0
Clkpr = 0
Declare Sub Receivemorse
Declare Sub Sendmorse
Do
For I = 1 To 5 'Zufällige Fünfergruppen A...Z
C = Rnd(24)
C = C + 2
If C = 19 Then C = 27
If C = 21 Then C = 28
Sendmorse
Waitms 300
Next I
Waitms 1500
Loop
Sub Receivemorse
C = 0
Do
Do
Loop Until S1 = 0
T = 0
Do
For M = 1 To 10
For N = 1 To 250 'ca. 520 kHz
Led1 = 1
Led1 = 0
Next N
Waitms 1 'ca 1 kHz AM
Next M
T = T + 1
Loop Until S1 = 1
Waitms 10
If T > 15 Then
C = C + B
End If
Shift B , Left
T = 0
Do
Waitms 10
T = T + 1
Loop Until S1 = 0 Or T > 25
Loop Until T > 25
End Sub
Sub Sendmorse
J = 1
Do
Shift C , Left
B = C And 128
J = J + 1
Loop Until B = 128
Do
Shift C , Left
J = J + 1
B = C And 128
If B = 128 Then
For T = 1 To 240
For N = 1 To 250 'ca. 520 kHz
Led1 = 1
Led1 = 0
Next N
Waitms 1 'ca 1 kHz AM
Next T
Else
For T = 1 To 80
For N = 1 To 250 'ca. 520 kHz
Led1 = 1
Led1 = 0
Next N
Waitms 1 'ca 1 kHz AM
Next T
End If
Waitms 100
Loop Until J = 8
End Sub
'Sparrow_Morse_Memory.bas
$regfile = "attiny13.dat"
$crystal = 9600000
$hwstack = 8
$swstack = 4
$framesize = 4
Led1 Alias Portb.1
Led2 Alias Portb.3
S1 Alias Pinb.0
S2 Alias Pinb.2
Config Portb = &B000011010
Dim D As Byte
Dim T As Byte
Dim B As Byte
Dim C As Byte
Dim N As Byte
Dim M As Byte
Dim I As Byte
Dim J As Byte
Dim A As Byte
Clkpr = 128 '9,6 MHz
Clkpr = 0
Clkpr = 0
Declare Sub Receivemorse
Declare Sub Sendmorse
Do
A = 0
Do
Readeeprom C , A
If C < 255 Then Sendmorse
A = A + 1
Waitms 300
Loop Until C = 255
A = 0
Do
T = 0
Do
Waitms 10
T = T + 1
If T > 30 Then T = 30
Loop Until S1 = 0
If T = 30 Then
D = 1
Writeeeprom D , A
A = A + 1
End If
Receivemorse
D = C
Writeeeprom D , A
A = A + 1
If C = &B00101010 Then
D = 255
Writeeeprom D , A
End If
Loop Until D = 255
Loop
Sub Receivemorse
C = 1
Do
Shift C , Left
Do
Loop Until S1 = 0
T = 0
Do
For M = 1 To 10
For N = 1 To 250 'ca. 520 kHz
Led1 = 1
Led1 = 0
Next N
Waitms 1
Next M
T = T + 1
Loop Until S1 = 1
' Pwm0b = 0
Waitms 10
If T > 15 Then
C = C + 1
End If
Shift B , Left
T = 0
Do
Waitms 10
T = T + 1
Loop Until S1 = 0 Or T > 25
Loop Until T > 25
End Sub
Sub Sendmorse
If C = 1 Then
Waitms 300
Else
J = 1
Do
Shift C , Left
B = C And 128
J = J + 1
Loop Until B = 128
Do
Shift C , Left
J = J + 1
B = C And 128
If B = 128 Then
For T = 1 To 240
For N = 1 To 250 'ca. 520 kHz
Led1 = 1
Led1 = 0
Next N
Waitms 1 'ca 1 kHz AM
Next T
Else
For T = 1 To 80
For N = 1 To 250 'ca. 520 kHz
Led1 = 1
Led1 = 0
Next N
Waitms 1 'ca 1 kHz AM
Next T
End If
Waitms 100
Loop Until J = 8
End If
End Sub
A = 0
Do
T = 0
Do
Waitms 10
T = T + 1
If T > 30 Then T = 30
'Löschen
If S2 = 0 Then
Do
Waitms 100
Loop Until S2 = 1 'Ein Zeichen löschen
A = A - 1
Waitms 100
End If
'Loschen Ende
Loop Until S1 = 0
If T = 30 Then
D = 1
Writeeeprom D , A
A = A + 1
End If
Receivemorse
D = C
Writeeeprom D , A
A = A + 1
If C = &B00101010 Then
D = 255
Writeeeprom D , A
End If
Loop Until D = 255