基于单片机的智能路灯控制系统..

上传人:博****1 文档编号:508284101 上传时间:2023-12-15 格式:DOC 页数:10 大小:177.50KB
返回 下载 相关 举报
基于单片机的智能路灯控制系统.._第1页
第1页 / 共10页
基于单片机的智能路灯控制系统.._第2页
第2页 / 共10页
基于单片机的智能路灯控制系统.._第3页
第3页 / 共10页
基于单片机的智能路灯控制系统.._第4页
第4页 / 共10页
基于单片机的智能路灯控制系统.._第5页
第5页 / 共10页
点击查看更多>>
资源描述

《基于单片机的智能路灯控制系统..》由会员分享,可在线阅读,更多相关《基于单片机的智能路灯控制系统..(10页珍藏版)》请在金锄头文库上搜索。

1、元件清单名称型号数量(个)单片机AT89S521RS-232标准串口设计的接口电路MAX2321串口DB91光耦MOC30521双电压比较器LM3931稳压管LM78051变压器220V转9V1二极管IN40072三极管90131可控硅BTA081LED灯发光二极管1灯泡220V 40W的白炽灯1滑动变阻器100K1光敏电阻LG44162电阻1001330110K51K1150K2电容103110421054电解电容10pF210uF11000uF/25F12200uF/25F1P1.01P1.12P1.23P1.34P1.45P1.5/MOSI6P1.6/MISO7P1.7/SCK8RST9

2、P3.0/RXD10P3.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.5/T115P3.6/WR16P3.7/RD17XTAL218XTAL119GND20A8/P2.021A9/P2.122A10/P2.223A11/P2.324A12/P2.425A13/P2.526A14/P2.627A15/P2.728PESN29ALE/PROG30EA/VPP31P0.7/AD732P0.6/AD633P0.5/AD534P0.4/AD435P0.3/AD336P0.2/AD237P0.1/AD138P0.0/AD039VCC40U1AT89S52D3IN400

3、7L1LEDR11KR21KC1104C2104C5104Vin1GND2Vout3U5LM7805R310KR8100R410KVCC213T1BTA081264U2MOC3052C10103R6330R7330VCC C1+1V+2C1-3C2+4C2-5V-6T2out7R2in8R2out9T2in10T1in11R1out12R1in13T1out14GND15VCC16U4MAX232C6105C7105C9105C8105162738495J1DB9VCCVCCR510KS1SW-PBVCCC1230pFC1330pF12J29VVCCOUTPUT A1IUTPUT A+2 IU

4、TPUT A-3GND4 IUTPUT B-5 IUTPUT B+6OUTPUT B7VCC8J3LM393R1010KR14150KR910KR11150KVCC12J4220VR13100KR15100KC31000uF/25VC42200uF/25VY111.0592MU3LAMPC1110uFQ190135VR16LRR12LR1234J5K1Private Declare Sub Sleep Lib Kernel32 (ByVal dwMilliseconds As Long)通信Dim commflag As BooleanDim commstr(0 To 3) As Byte灯泡

5、状态 true 亮 false 灭Dim lightstate As Boolean故障指示灯状态 true 亮 false 灭Dim errorledstate As Boolean联机指示Dim connection As BooleanDim config As String/当点击“联机”按钮时或动其他按钮时,如果计算机和硬件未连接,会出现”端口打开错误”的命令窗口;如果计算机和硬件连接了,会出现”系统已联机”的字样。Private Sub Command1_Click()On Error GoTo out If Not connection ThenMe.MSComm1.CommPo

6、rt = Me.Combo1.ListIndex + 1 Me.MSComm1.PortOpen = True If Me.MSComm1.PortOpen = False Then MsgBox 端口打开错误, vbOKOnly, 错误 Else connection = Not connection Me.Label8.Caption = 系统已联机 Me.Label8.ForeColor = RGB(255, 0, 0) Me.Command1.Caption = 断开 commstr(0) = &HFF commstr(1) = &H1 commstr(2) = &H0 commstr

7、(3) = commstr(0) Xor commstr(1) Xor commstr(2) commflag = True Me.MSComm1.Output = commstr End If Else connection = Not connection Me.MSComm1.PortOpen = False Me.Label8.Caption = 系统未联机 Me.Label8.ForeColor = RGB(255, 255, 255) Me.Command1.Caption = 联机 lightstate = False errorledstate = False Me.leder

8、ror(0).FillColor = RGB(100, 100, 100)Me.ledstate(0).FillColor = RGB(100, 100, 100) End If GoTo out2out: MsgBox 端口打开错误, vbOKOnly, 错误out2:End SubPrivate Sub Form_Load()Dim timestr As StringMe.ledstate(0).FillColor = RGB(100, 100, 100)Me.lederror(0).FillColor = RGB(100, 100, 100)Me.Label3.Caption = Now

9、()Me.Combo1.ListIndex = 0/端口的参数设置串口MSComm1.Settings = 9600,n,8,1MSComm1.InputMode = 0 采用文本接收MSComm1.InBufferCount = 0 清空接受缓冲区MSComm1.OutBufferCount = 0 清空传输缓冲区MSComm1.RThreshold = 1 产生MSComm事件恢复时间config = App.Path + + config.iniOpen config For Input As #1 读取该汉字在16点阵字库中的原始字模Line Input #1, timestrMe.D

10、TPicker1.Value = timestrLine Input #1, timestrMe.DTPicker2.Value = timestrClose #1清发送标志commflag = FalseMe.Text1.Text = Str(Me.UpDown1.Value)errorledstate = Falselightstate = Falseconnection = FalseEnd SubPrivate Sub Form_Unload(Cancel As Integer)保存时间Dim timestr As Stringconfig = App.Path + + config.

11、iniOpen config For Output As #1 读取该汉字在16点阵字库中的原始字模Print #1, Me.DTPicker1.ValuePrint #1, Me.DTPicker2.ValueClose #1End Sub/当PC机发送“开灯”请求时,单片机回送“tuon”命令,开灯成功;当PC机发送“故障检测”请求时,单片机回送“trou”命令,说明灯泡故障,VB界面中的故障灯会亮,反之单片机回送“norm”命令,说明灯泡是好的,正常的,VB界面种的故障灯不会发生变化。Private Sub MSComm1_OnComm()Dim strBuff As StringSel

12、ect Case MSComm1.CommEvent Case 2 strBuff = MSComm1.Input If strBuff = ok Then commflag = False ElseIf strBuff = toff Then Me.ledstate(0).FillColor = RGB(100, 100, 100) lightstate = False commflag = False ElseIf strBuff = tuon Then Me.ledstate(0).FillColor = RGB(255, 0, 0) lightstate = True commflag = FalseElseIf strBuff = trou Then Me.lederror(0).FillColor = RGB(255, 0, 0) ElseIf strBuff = norm Then

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 研究生课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号