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

📄 form1.frm

📁 利用上位机(VB)界面
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "彩灯控制"
   ClientHeight    =   6930
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8025
   LinkTopic       =   "Form1"
   ScaleHeight     =   6930
   ScaleWidth      =   8025
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command6 
      Caption         =   "退出"
      Height          =   495
      Left            =   5400
      TabIndex        =   22
      Top             =   5640
      Width           =   1575
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   6240
      Top             =   6240
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.CommandButton Command1 
      Caption         =   "选择测试"
      Height          =   495
      Left            =   4680
      TabIndex        =   0
      Top             =   2400
      Width           =   975
   End
   Begin VB.Frame Frame1 
      Caption         =   "自动闪烁"
      Height          =   2175
      Left            =   480
      TabIndex        =   1
      Top             =   3240
      Width           =   7095
      Begin VB.CommandButton Command4 
         Caption         =   "结束"
         Height          =   375
         Left            =   5400
         TabIndex        =   20
         Top             =   1320
         Width           =   495
      End
      Begin VB.CommandButton Command3 
         Caption         =   "暂停"
         Height          =   375
         Left            =   4200
         TabIndex        =   19
         Top             =   1320
         Width           =   855
      End
      Begin VB.CommandButton Command2 
         Caption         =   "开始"
         Height          =   375
         Left            =   3360
         TabIndex        =   18
         Top             =   1320
         Width           =   495
      End
      Begin VB.ComboBox Combo1 
         Height          =   300
         Left            =   600
         TabIndex        =   17
         Text            =   "Combo1"
         Top             =   1440
         Width           =   2175
      End
      Begin VB.OptionButton Option4 
         Caption         =   "方式4"
         Height          =   255
         Left            =   5160
         Style           =   1  'Graphical
         TabIndex        =   16
         Top             =   600
         Width           =   1095
      End
      Begin VB.OptionButton Option3 
         Caption         =   "方式3"
         Height          =   255
         Left            =   3480
         Style           =   1  'Graphical
         TabIndex        =   15
         Top             =   600
         Width           =   1095
      End
      Begin VB.OptionButton Option2 
         Caption         =   "方式2"
         Height          =   255
         Left            =   1920
         Style           =   1  'Graphical
         TabIndex        =   14
         Top             =   600
         Width           =   1095
      End
      Begin VB.OptionButton Option1 
         Caption         =   "方式1"
         Height          =   255
         Left            =   480
         Style           =   1  'Graphical
         TabIndex        =   13
         Top             =   600
         Value           =   -1  'True
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "闪烁速度设定"
         Height          =   375
         Left            =   360
         TabIndex        =   2
         Top             =   1080
         Width           =   1335
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "人工调试"
      Height          =   2415
      Left            =   480
      TabIndex        =   3
      Top             =   720
      Width           =   7095
      Begin VB.CommandButton Command5 
         Caption         =   "自动测试"
         Height          =   495
         Left            =   1320
         TabIndex        =   12
         Top             =   1680
         Width           =   975
      End
      Begin VB.CheckBox Check8 
         Caption         =   "LED8"
         Height          =   735
         Left            =   5040
         TabIndex        =   11
         Top             =   960
         Width           =   735
      End
      Begin VB.CheckBox Check7 
         Caption         =   "LED7"
         Height          =   735
         Left            =   3720
         TabIndex        =   10
         Top             =   960
         Width           =   855
      End
      Begin VB.CheckBox Check6 
         Caption         =   "LED6"
         Height          =   735
         Left            =   2520
         TabIndex        =   9
         Top             =   960
         Width           =   735
      End
      Begin VB.CheckBox Check5 
         Caption         =   "LED5"
         Height          =   735
         Left            =   1080
         TabIndex        =   8
         Top             =   960
         Width           =   735
      End
      Begin VB.CheckBox Check4 
         Caption         =   "LED4"
         Height          =   735
         Left            =   5040
         TabIndex        =   7
         Top             =   240
         Width           =   855
      End
      Begin VB.CheckBox Check3 
         Caption         =   "LED3"
         Height          =   735
         Left            =   3720
         TabIndex        =   6
         Top             =   240
         Width           =   735
      End
      Begin VB.CheckBox Check2 
         Caption         =   "LED2"
         Height          =   735
         Left            =   2520
         TabIndex        =   5
         Top             =   240
         Width           =   735
      End
      Begin VB.CheckBox Check1 
         Caption         =   "LED1"
         Height          =   735
         Left            =   1080
         TabIndex        =   4
         Top             =   240
         Width           =   735
      End
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "designed by 自动化0503 梁兆勇"
      Height          =   615
      Left            =   720
      TabIndex        =   21
      Top             =   5760
      Width           =   2775
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()  '按钮代码 02H
Dim chtest_signal(2) As Byte
chtest_signal(0) = &H2
'读取复选框的设置,并转换成一个16进制的数值
chtest_signal(1) = Check1.Value * &H80 + Check2.Value * &H40 + Check3.Value * &H20 + Check4.Value * &H10 + Check5.Value * &H8 + Check6.Value * &H4 + Check7.Value * &H2 + Check8.Value * &H1
chtest_signal(2) = &H0
MSComm1.PortOpen = True '打开串行口
MSComm1.Output = chtest_signal()
MSComm1.PortOpen = False '关闭串行口

End Sub

Private Sub Command2_Click()   '开始按钮 信号代码03h
Command2.Enabled = False
Dim sendata(2) As Byte
Dim Y As Byte
sendata(0) = &H3   '第一个代码按钮识别

If Option1.Value = True Then     '闪烁方式识别
sendata(1) = &H81
ElseIf Option2.Value = True Then
sendata(1) = &H82
ElseIf Option3.Value = True Then
sendata(1) = &H83
ElseIf Option4.Value = True Then
sendata(1) = &H84
End If

If Combo1.ListIndex = -1 Then
Y = MsgBox("请选择闪烁速度", vbRetryCancel + vbExclamation + vbDefaultButton1, "wrong")
End If

If Y = 4 Or Y = 2 Then GoTo esc


sendata(2) = Combo1.ListIndex


'sendata(0) = Val(Option1.Value) * &H1 + Val(Option2.Value) * &H2 + Val(Option3.Value) * &H4 + Val(Option4) * &H8
MSComm1.PortOpen = True '打开串行口

MSComm1.Output = sendata
MSComm1.PortOpen = False '关闭串行口

'If Combo1.ListIndex = -1 Then
'y = MsgBox("请选择闪烁速度", vbRetryCancel + vbExclamation + vbDefaultButton1, "wrong")
'End If

'If (y = 4) Or (y = 2) Then
'Command2.Enabled = False
'Command2.Enabled = True
'GoTo esc
'End If
esc:

Command2.Enabled = True

End Sub

Private Sub Command3_Click()  '暂停按钮 信号代码04  暂停变继续 05
Dim pausebut(2) As Byte
'MSComm1.PortOpen = True '打开串行口
'pausebut(0) = &H82
'MSComm1.Output = pausebut()
'MSComm1.PortOpen = False '关闭串行口

If Command3.Caption = "继续" Then
Command3.Caption = "暂停"
MSComm1.PortOpen = True '打开串行口
pausebut(0) = &H4
pausebut(1) = &H0
pausebut(2) = &H0
MSComm1.Output = pausebut()
MSComm1.PortOpen = False '关闭串行口

Else: Command3.Caption = "继续"
MSComm1.PortOpen = True '打开串行口
pausebut(0) = &H5
pausebut(1) = &H0
pausebut(2) = &H0
MSComm1.Output = pausebut()
MSComm1.PortOpen = False '关闭串行口
End If

End Sub

Private Sub Command4_Click()  '结束按钮 信号代码 06
Command4.Enabled = False
Dim shopbut(2) As Byte
MSComm1.PortOpen = True '打开串行口
shopbut(0) = &H6
shopbut(1) = &H0
shopbut(2) = &H0
MSComm1.Output = shopbut()
MSComm1.PortOpen = False '关闭串行口
Command4.Enabled = True
End Sub

Private Sub Command5_Click() '对应自动测试按钮 信号代码为01h
Dim AUtest_signal(2) As Byte
MSComm1.PortOpen = True '打开串行口
AUtest_signal(0) = &H1
AUtest_signal(1) = &H0
AUtest_signal(2) = &H0
MSComm1.Output = AUtest_signal()
MSComm1.PortOpen = False '关闭串行口
    
End Sub

Private Sub Form_Load()
MSComm1.CommPort = 1  '设置端口号为1
MSComm1.Settings = "4800,N,8,1 " '设置波特率4800 无校验  8位数据  1停止位


Dim Tme(0 To 3)
Dim i

Tme(0) = "0.5秒"   '提供的四种闪烁速度选择项
Tme(1) = "1秒"
Tme(2) = "2秒"
Tme(3) = "3秒"

For i = 0 To 3
Combo1.AddItem Tme(i) '在组合框中添加所有供选择的速度
Next i

Combo1.Text = Combo1.List(0)  '默认选择0.5秒
Combo1.Text = "请选择闪烁速度"
  
End Sub

Private Sub Label1_Click()

End Sub

⌨️ 快捷键说明

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