[Visual Basic 6.0] 軟硬體結合運用 89S51 8X8 矩陣 LED 代碼產生器

摘要:[Visual Basic 6.0] 軟硬體結合運用 89S51 8X8 矩陣 LED 代碼產生器

[Visual Basic 6.0] 軟硬體結合運用 89S51 8X8 矩陣 LED 代碼產生器

 

當遇上專題製作時又不想慢慢計算 8x8 矩陣 LED 時就是它了!

# 打勾則亮 ( 此程式為範例可能無法套用至每一個電路請自行修改程式碼 )

'# [Visual Basic 6.0] 軟硬體結合運用 89S51 8X8 矩陣 LED 代碼產生器
'# 0xDe
Dim LEDCode(1 To 8, 1 To 8)

Private Sub Form_Load()
Me.Caption = "軟件初始化...請稍後..." ' 初始化
'----------初始化物件名稱
For I = 0 To 7 '初始化 ' LED直() LED橫() 陣列中的名稱
    LED直(I).Caption = LED直(I).Caption & I + 1
    LED橫(I).Caption = LED橫(I).Caption & I + 1
Next I
For I = 1 To 8 ' 建立二維陣列與系統連結
    For J = 1 To 8
        LEDCode(I, J) = N
        N = N + 1
    Next J
Next I
Me.Caption = "89S51 8X8 LED 廖憲得 (0xDe) 設計" ' 初始化完成
End Sub

Private Sub LED直_Click(Index As Integer)
For I = 1 To 8
    If LED(LEDCode(Index + 1, I)).Value = 1 Then
        LED(LEDCode(Index + 1, I)).Value = 0
    Else
        LED(LEDCode(Index + 1, I)).Value = 1
    End If
Next I
End Sub
Private Sub LED橫_Click(Index As Integer)
For I = 1 To 8
    If LED(LEDCode(I, Index + 1)).Value = 1 Then
        LED(LEDCode(I, Index + 1)).Value = 0
    Else
        LED(LEDCode(I, Index + 1)).Value = 1
    End If
Next I
End Sub

Private Sub 全部取消_Click()
For I = 1 To 8
    For J = 1 To 8
        LED(LEDCode(I, J)).Value = 0
    Next J
Next I
End Sub

Private Sub 全部發亮_Click()
For I = 1 To 8
    For J = 1 To 8
        LED(LEDCode(I, J)).Value = 1
    Next J
Next I
End Sub

Private Sub 輸出目前_Click()
X = ""
Y = ""
For I = 1 To 8
    For J = 1 To 8
        If LED(LEDCode(I, J)).Value = 1 Then
            X = X & " , " & Val(I)
            Y = Y & " , " & Val(J)
        End If
    Next J
Next I

Text1.Text = Mid(X, 3) & vbCrLf & Mid(Y, 3)
End Sub

 

[Visual Basic 6.0] 軟硬體結合運用 89S51 8X8 矩陣 LED 代碼產生器.rar

#0xDe 從分享中學習

#Facebook:ProgrammerDe (https://www.facebook.com/MicrosoftDes) 有問題歡迎提問