我把车门中控锁改为单键的密码锁了
忍不住,有把车门改为及其变态的形式弊人老了,汽车钥匙也懒得带着,麻烦s了。搞了一个汽车电码开门锁的功能,和中控锁连起来使用,效果很佳,很省事。
输对了密码大门打开。输错了密码就不与理会。车子外面只暴露一个隐蔽的防水开关当做输密码电件使用,下一步要改为红外感应的,连电件也省了。
$regfile = "2313DEF.dat"
$crystal = 1000000 ' 定义单片机时钟周期是1000000Hz
Config Watchdog = 2048 '看门狗
Start Watchdog '启动看门狗
Config Portb = Input
Config Portd = Output
Dim A As Integer
Dim Count As Integer
Dim Count_key As Integer
Dim Key As Long
Portd.5 = 1 '指示灯随着看门狗闪烁
Waitms 30
Portd.5 = 0
Key = 0
Reset Watchdog '喂狗
Loop2:
If Pinb.0 = 1 Then Reset Watchdog
Gosub Getkey '去读键盘
If Count_key = 2 Then '键盘得到 划
Key = Key * 10 '密码左移一位
Key = Key + 1 '密码赴值
Reset Watchdog
End If
If Count_key = 1 Then '键盘得到 点
Key = Key * 10
Reset Watchdog
End If
If Key = 11110000 Then '锁车门的电码
Portd.2 = 1 '启动电磁阀开门
Waitms 400 '延时
Portd.2 = 0
Waitms 400
Portd.2 = 1 '保险起见再锁一次
Waitms 400
Portd.2 = 0
Key = 0
End If
If Key = 11110001 Then '开门的电码
Portd.3 = 1 '启动电磁阀开门
Waitms 400 '延时
Portd.3 = 0
Waitms 400
Portd.3 = 1 '保险起见再开一次
Waitms 400
Portd.3 = 0
Key = 0
End If
Goto Loop2
End
Getkey:
Count = 0
Count_key = 0
Portd.6 = 0
Do
If Pinb.0 = 1 Then Reset Watchdog
Count = Count + 1
Waitms 1
Loop Until Pinb.0 = 0
If Count > 30 Then '如果按建时间超过30小于100算点
If Count < 100 Then
Reset Watchdog
Rem Portd.6 = 1
Rem Waitms 100
Rem Portd.6 = 0
Count_key = 1
Reset Watchdog
End If
End If
If Count > 200 Then '按建时间超过200算划
Reset Watchdog
Rem Portd.6 = 1
Rem Waitms 100
Rem Portd.6 = 0
Count_key = 2
Reset Watchdog
End If
Return 现在都是RKE和PKE了,改成这两种 对着车子“指指点点”,车门就开了,楼主小心被人当贼~~~~~ 应该把照片传上来欣赏一下。
PS:启动发动机还需要钥匙吧? 照片可“土”了,就是一个电路板,一个avr驱动两个继电器,继电器输出直接连接中控锁控制器。外壳是用旧的网线测试仪改装的。车子外面只有一个摁钮隐藏在反光镜的底下。 我看你干脆改成 指纹识别 或者 虹膜识别 不就更省事了嘛,这样只要摸一下或者看一眼车门就开了,不是更好。 不明白,一键如何能做锁?至少也要两键呀(0和1)
莫非楼主计时功能超强,用时间长短来表示?那你老婆咋办? 没有遥控开锁功能吗? 拍 摩尔斯电报码?? yes,按morse电码开门的。 .......morse电码
论坛果然强人辈出 楼主,你这个有C语的吗?我想做个在大门上,谢谢!
页:
[1]