⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frm_prog3.frm

📁 51单片机模拟I2C的实例
💻 FRM
📖 第 1 页 / 共 3 页
字号:
      Y2              =   1080
   End
   Begin VB.Line Line3 
      Index           =   0
      X1              =   1440
      X2              =   1680
      Y1              =   1080
      Y2              =   1080
   End
   Begin VB.Line Line2 
      Index           =   0
      X1              =   1680
      X2              =   1560
      Y1              =   1080
      Y2              =   1440
   End
   Begin VB.Line Line1 
      Index           =   0
      X1              =   1440
      X2              =   1560
      Y1              =   1080
      Y2              =   1440
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "Led1"
      Height          =   255
      Index           =   0
      Left            =   1320
      TabIndex        =   0
      Top             =   1920
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   0
      Left            =   1320
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape3 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   135
      Index           =   0
      Left            =   1440
      Shape           =   3  'Circle
      Top             =   1620
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   0
      Left            =   1440
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   1
      Left            =   2040
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   3
      Left            =   3480
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   7
      Left            =   6360
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Line Line1 
      Index           =   6
      X1              =   5760
      X2              =   5880
      Y1              =   1080
      Y2              =   1440
   End
   Begin VB.Line Line1 
      Index           =   5
      X1              =   5040
      X2              =   5160
      Y1              =   1080
      Y2              =   1440
   End
   Begin VB.Line Line1 
      Index           =   4
      X1              =   4320
      X2              =   4440
      Y1              =   1080
      Y2              =   1440
   End
   Begin VB.Line Line2 
      Index           =   2
      X1              =   3120
      X2              =   3000
      Y1              =   1080
      Y2              =   1440
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   1
      Left            =   2160
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   3
      Left            =   3600
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   7
      Left            =   6480
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   2
      Left            =   2760
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   6
      Left            =   5640
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   5
      Left            =   4920
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   4
      Left            =   4200
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   2
      Left            =   2880
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   4
      Left            =   4320
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   5
      Left            =   5040
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   6
      Left            =   5760
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   11
      Left            =   9240
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   10
      Left            =   8520
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   9
      Left            =   7800
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   8
      Left            =   7080
      Shape           =   3  'Circle
      Top             =   840
      Width           =   495
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   11
      Left            =   7920
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   10
      Left            =   8640
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   9
      Left            =   9360
      Top             =   1200
      Width           =   255
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   495
      Index           =   8
      Left            =   7200
      Top             =   1200
      Width           =   255
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
Dim a As Integer

    ' set all pins low
    OUTPORT 888, 0
    ' xor 11 is that pin 1, 2 and 4 are inverse
    OUTPORT 890, 0 Xor 11
    
    
    ' this is only for the screen
    For a = 0 To 11
        Shape1(a).BackColor = RGB(255, 255, 255)
    Next a

End Sub

Private Sub Form_Load()
    ' set all pins low
    OUTPORT 888, 0
    ' xor 11 is that pin 1, 2 and 4 are inverse
    OUTPORT 890, 0 Xor 11
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim a As Integer
    
    ' 0   = 0
    ' 1   = 2 ^ 0
    ' 2   = 2 ^ 1 = 2 * 2
    ' 4   = 2 ^ 2 = 2 * 2 * 2
    ' 8   = 2 ^ 3 = 2 * 2 * 2* 2
    ' 16  = 2 ^ 4 = 2 * 2 * 2* 2* 2
    ' 32  = 2 ^ 5 = 2 * 2 * 2* 2* 2* 2
    ' 64  = 2 ^ 6 = 2 * 2 * 2* 2* 2* 2* 2
    ' 128 = 2 ^ 7 = 2 * 2 * 2* 2* 2* 2* 2* 2
   
    'This is to look in wich area the mouse has been clicked
    ' pin 2 to 9 with basic address 888
    For a = 0 To 7
        Shape1(a).BackColor = RGB(255, 255, 255)
        If (X >= (1320 + (a * 720))) And (X < (1320 + ((a + 1) * 720))) And (Y > 840) And (Y < 1760) Then
            ' 888 = lpt1 and the number is what goes to the lpt port
           OUTPORT 888, 2 ^ a
           OUTPORT 888 + 2, 0
           Shape1(a).BackColor = RGB(255, 0, 0)
        End If
    Next a
    
    'This is to look in wich area the mouse has been clicked
    ' basic address 888 + 2
    For a = 8 To 11
        Shape1(a).BackColor = RGB(255, 255, 255)
        If (X >= (1320 + (a * 720))) And (X < (1320 + ((a + 1) * 720))) And (Y > 840) And (Y < 1760) Then
            ' 888+2 = lpt1 and the number is what goes to the lpt port
            OUTPORT 888, 0
            OUTPORT 888 + 2, ((2 ^ (a - 8)) Xor 11)
            Shape1(a).BackColor = RGB(255, 0, 0)
        End If
    Next a
    
    
    
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -