code cua K1
Private Declare Sub Out32 Lib "inpout32.dll" (ByVal Portaddress As Integer, ByVal value As Integer)
Private Declare Function Inp32 Lib "inpout32.dll" (ByVal Portaddress As Integer) As Integer
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub tu_dieu_khien(ByVal x1 As Integer) '**chuong trinh viet len tu dieu khien
Out32 Val("&H37A"), 4 'thiet lap /RD=1,/WR=1,A1A0=11
Out32 Val("&H378"), x1 'ghi gia tri vao tu dieu khien
Out32 Val("&H37A"), 12 'tich cuc thap cho /WR
Sleep (10)
Out32 Val("&H37A"), 4 'tra lai muc cao cho /WR
End Sub
Private Sub PA(ByVal y1 As Integer) '**chuong trinh con xuat du lieu ra Port A
Out32 Val("&H37A"), 7 'dat muc cao cho /WR
Out32 Val("&H378"), y1 'dat gia tri truyen tu portD ra portA
Out32 Val("&H37A"), 15 'dat muc tich cuc thap cho /WR
End Sub
Private Sub PB(ByVal y1 As Integer) '**chuong trinh con xuat du lieu ra Port B
Out32 Val("&H37A"), 6 'dat muc cao cho /WR
Out32 Val("&H378"), y1 'dat gia tri truyen tu portD ra portA
Out32 Val("&H37A"), 14 'dat muc tich cuc thap cho /WR
End Sub
Private Sub PC(ByVal y1 As Integer) '**chuong trinh con xuat du lieu ra Port C
Out32 Val("&H37A"), 5 'dat muc cao cho /WR
Out32 Val("&H378"), y1 'dat gia tri truyen tu portD ra portA
Out32 Val("&H37A"), 13 'dat muc tich cuc thap cho /WR
End Sub
Private Sub Command1_Click()
Dim mang_cau(10000) As Variant '**khai bao mang
Dim ABC(10000) As Variant
Dim AB(10000) As Variant
Dim mangcot, Space, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
'**font chu cai**
mangcot = Array(&HFE, &HFD, &HFB, &HF7, &HEF, &HDF, &HBF, &H7F)
Space = Array(&H0, &H0, &H0, &H0, &H0, &H0, &H0)
A = Array(&HFC, &HFE, &H11, &H11, &HFE, &HFC, &H0)
B = Array(&HFF, &HFF, &H89, &H89, &H89, &H76, &H0)
C = Array(&H7E, &HFF, &H81, &H81, &H81, &H42, &H0)
D = Array(&HFF, &HFF, &H81, &H81, &H81, &H7E, &H0)
E = Array(&HFF, &HFF, &H89, &H89, &H89, &H81, &H0)
F = Array(&HFF, &HFF, &H9, &H9, &H9, &H1, &H0)
G = Array(&H7E, &HFF, &H81, &H81, &H91, &H72, &H0)
H = Array(&HFF, &HFF, &H18, &H18, &HFF, &HFF, &H0)
I = Array(&HC3, &HC3, &HFF, &HFF, &HC3, &HC3, &H0)
J = Array(&H41, &H81, &HFF, &H7F, &H1, &H1, &H0)
K = Array(&HFF, &HFF, &H18, &H24, &H42, &H81, &H0)
L = Array(&HFF, &HFF, &HC0, &HC0, &HC0, &HC0, &H0)
M = Array(&HFF, &H2, &H4, &H4, &H2, &HFF, &H0)
N = Array(&HFF, &HFF, &HC, &H30, &HFF, &HFF, &H0)
O = Array(&H7E, &HFF, &HC3, &HC3, &HFF, &H7E, &H0)
P = Array(&HFF, &HFF, &H9, &H9, &H9, &H6, &H0)
Q = Array(&H7E, &H81, &H81, &HA1, &H41, &HBE, &H0)
R = Array(&HFF, &HFF, &H19, &H29, &H49, &H86, &H0)
S = Array(&H42, &H85, &H89, &H91, &HA1, &H42, &H0)
T = Array(&H3, &H3, &HFF, &HFF, &H3, &H3, &H0)
U = Array(&H7F, &HFF, &HC0, &HC0, &HFF, &H7F, &H0)
V = Array(&H3F, &H40, &H80, &H80, &H40, &H3F, &H0)
W = Array(&H7F, &H80, &HF8, &HF8, &H80, &H7F, &H0)
X = Array(&HC3, &H24, &H18, &H18, &H24, &HC3, &H0)
Y = Array(&H3, &H6, &H8C, &HC8, &H7F, &H3F, &H0)
Z = Array(&HC3, &HE3, &HD3, &HCB, &HC7, &HC3, &H0)
'*******ghep tao mang lon*******
For i1 = 0 To 188
If i1 < 7 Then ABC(i1) = Space(i1)
If (i1 >= 7) And (i1 < 14) Then ABC(i1) = A(i1 - 7)
If (i1 >= 14) And (i1 < 21) Then ABC(i1) = B(i1 - 14)
If (i1 >= 21) And (i1 < 28) Then ABC(i1) = C(i1 - 21)
If (i1 >= 28) And (i1 < 35) Then ABC(i1) = D(i1 - 28)
If (i1 >= 35) And (i1 < 42) Then ABC(i1) = E(i1 - 35)
If (i1 >= 42) And (i1 < 49) Then ABC(i1) = F(i1 - 42)
If (i1 >= 49) And (i1 < 56) Then ABC(i1) = G(i1 - 49)
If (i1 >= 56) And (i1 < 63) Then ABC(i1) = H(i1 - 56)
If (i1 >= 63) And (i1 < 70) Then ABC(i1) = I(i1 - 63)
If (i1 >= 70) And (i1 < 77) Then ABC(i1) = J(i1 - 70)
If (i1 >= 77) And (i1 < 84) Then ABC(i1) = K(i1 - 77)
If (i1 >= 84) And (i1 < 91) Then ABC(i1) = L(i1 - 84)
If (i1 >= 91) And (i1 < 98) Then ABC(i1) = M(i1 - 91)
If (i1 >= 98) And (i1 < 105) Then ABC(i1) = N(i1 - 98)
If (i1 >= 105) And (i1 < 112) Then ABC(i1) = O(i1 - 105)
If (i1 >= 112) And (i1 < 119) Then ABC(i1) = P(i1 - 112)
If (i1 >= 119) And (i1 < 126) Then ABC(i1) = Q(i1 - 119)
If (i1 >= 126) And (i1 < 133) Then ABC(i1) = R(i1 - 126)
If (i1 >= 133) And (i1 < 140) Then ABC(i1) = S(i1 - 133)
If (i1 >= 140) And (i1 < 147) Then ABC(i1) = T(i1 - 140)
If (i1 >= 147) And (i1 < 154) Then ABC(i1) = U(i1 - 147)
If (i1 >= 154) And (i1 < 161) Then ABC(i1) = V(i1 - 154)
If (i1 >= 161) And (i1 < 168) Then ABC(i1) = W(i1 - 161)
If (i1 >= 168) And (i1 < 175) Then ABC(i1) = X(i1 - 168)
If (i1 >= 175) And (i1 < 182) Then ABC(i1) = Y(i1 - 175)
If (i1 >= 182) And (i1 < 189) Then ABC(i1) = Z(i1 - 182)
Next i1 'CO DC CHUOI BANG CHU CAI
'*******xu ly cau nhap vao*******
Text = UCase(Trim(Text1.Text)) 'cat ki tu spase truoc sau cau va doi thanh chu hoa
sokt = Len(Text) 'dem so ki tu trong text
If sokt = 0 Then
MsgBox "moi ban nhap dong chu"
Exit Sub
End If
For i2 = 1 To sokt
AB(i2) = Asc(Mid(Text, i2, 1)) 'mang ki tu o dang so ascii
If (((AB(i2) < 65) And (AB(i2) <> 32)) Or (AB(i2) > 90)) Then '**kiem tra ki tu khong hop le
MsgBox "ban da nhap sai.Moi ban nhap lai"
Exit Sub 'lenh thoat khoi thu tuc
End If
Next i2
'*******xay dung chuoi cau*******
'*******16 phan tu dau tien*******
For i5 = 0 To 15
mang_cau(i5) = &H0
Next i5
'******cac phan tu tiep theo*******
For i2 = 1 To sokt
For i3 = 0 To 6
mang_cau(7 * (i2 - 1) + i3 + 16) = ABC((AB(i2) Mod 64) * 7 + i3)
Next i3
Next i2 'co mang cua cau nhap vao
'***16 phan tu cuoi******
For i5 = 7 * sokt + 16 To 7 * sokt + 32
mang_cau(i5) = &H0
Next i5
'****QUET LED****
tu_dieu_khien (128) 'ghi tu dieu khien chon che do 0
Do While 1 'lap vo tan
For x4 = 0 To (7 * sokt + 23)
For i4 = 0 To 600
For j4 = 0 To 7
y1 = mang_cau(x4 + j4)
PB (y1) 'xuat du lieu ra Port B
y1 = mang_cau(x4 + j4 + 8)
PC (y1) 'xuat du lieu ra Port C
y1 = mangcot(j4)
PA (y1) 'xuat du lieu ra Port B
Sleep (0.5) 'tao tre
PA (255) 'dua 8 bit Port A ve muc cao
Sleep (0.5)
Next j4
x123 = Inp32(&H379) 'doc gia tri o thanh ghi trang thai
If (x123 And &H80) = &H80 Then Exit Do '**kiem tra thanh ghi trang thai**
Next i4
Next x4
Loop
End Sub
Private Sub Command2_Click()
Text1.Text = ""
End Sub
Bạn đang đọc truyện trên: Truyen247.Pro