stc89c52做的密码锁

  我们宿舍经常忘带钥匙,所以自己用stc89c52弄个密码锁(其实用个stc12c2052那种20个脚的就可以了~),其实还可以加上修改密码的功能,再有可能的话加上那种非接触式ic卡,关于这个ic卡这个自己还不知怎么弄。

非常简单,就是在键盘扫描基础上加几个代码。

[sourcecode language="c"]

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar linshi,key;
sbit bibi=P3^4;
uchar code table[]={
 
                0x3F,  //"0"
                0x06,  //"1"
                0x5B,  //"2"
                0x4F,  //"3"
                0x66,  //"4"
                0x6D,  //"5"
                0x7D,  //"6"
                0x07,  //"7"
                0x7F,  //"8"
                0x6F,  //"9"
 
                         };

void yanshi(uint x)
 {
  uchar j;
  uint i;
  for(i=x;i>0;i--)
   for(j=110;j>0;j--);
 }
void xianshi(uchar a)
 {
   P1=0xff;
  P2=table[a];
 }
void didi(uint a)
 {
  bibi=0;
  yanshi(a);
  bibi=1;
  yanshi(200);
 }

void scan()
 {
   uchar temp;
   P0=0xfe;
   temp=P0;
   temp=temp&0xf0;
   if(temp!=0xf0)
    {
    yanshi(10);
    temp=P0;
    temp=temp&0xf0;
    if(temp!=0xf0)
     {
      linshi=linshi+1;
       temp=P0;
      switch(temp)
       {
         case 0xee:
          key=0;
         break;
         case 0xde:
          key=1;
         break;
         case 0xbe:
          key=2;
         break;
         case 0x7e:
          key=3;
         break;
       }
      while(temp!=0xf0)
       {
         temp=P0;
        temp=temp&0xf0;
       }
      didi(50);
              
     }
   }
   P0=0xfd;
   temp=P0;
   temp=temp&0xf0;
   if(temp!=0xf0)
    {
    yanshi(10);
    temp=P0;
    temp=temp&0xf0;
    if(temp!=0xf0)
     {
      linshi=linshi+1;
       temp=P0;
      switch(temp)
       {
         case 0xed:
          key=4;
         break;
         case 0xdd:
          key=5;
         break;
         case 0xbd:
          key=6;
         break;
         case 0x7d:
          key=7;
         break;
       }
      while(temp!=0xf0)
       {
         temp=P0;
        temp=temp&0xf0;
       }
      didi(50);
              
     }
   }
   P0=0xfb;
   temp=P0;
   temp=temp&0xf0;
   if(temp!=0xf0)
    {
    yanshi(10);
    temp=P0;
    temp=temp&0xf0;
    if(temp!=0xf0)
     {
      linshi=linshi+1;
       temp=P0;
      switch(temp)
       {
         case 0xeb:
          key=8;
         break;
         case 0xdb:
          key=9;
         break;
         case 0xbb:
          key=0;
         break;
         case 0x7b:
          key=1;
         break;
       }
      while(temp!=0xf0)
       {
         temp=P0;
        temp=temp&0xf0;
       }
      didi(50);
              
     }
   }
   

 }

void main()
 {
  uchar pd[]={1,5,8,7,5,5};
  uchar haha[6];
  linshi=0;
  while(1)
   {
   
   scan();
   if(linshi==0)
    scan();
   if(linshi==1)
    {
     haha[0]=key;
     xianshi(haha[0]);
    }
   if(linshi==2)
    {
     haha[1]=key;
     xianshi(haha[1]);
    }
   if(linshi==3)
    {
     haha[2]=key;
     xianshi(haha[2]);
    }
   if(linshi==4)
    {
     haha[3]=key;
     xianshi(haha[3]);
    }
   if(linshi==5)
    {
     haha[4]=key;
     xianshi(haha[4]);
    }    
   if(linshi==6)
    {
     haha[5]=key;
     xianshi(haha[5]);
     if(haha[5]==pd[5]&&haha[4]==pd[4]&&haha[3]==pd[3]&&haha[2]==pd[2]&&haha[1]==pd[1]&&haha[0]==pd[0])
       didi(700);
     else
      {
       didi(700);
       didi(700);
      }
     linshi=0;
    }
       }
 }

[/sourcecode]

批处理更改ip

网上收集的~因为我们公司限制了网速,所以自己就通过更改IP来突破限制(*^__^*) !手动更改太麻烦了所以就找了个批处理,再不行就更该mac地址!

@echo off
cd
echo windows快速更改ip地址和网关

rem ****************************************************
rem   请修改下面的设置
rem NIC是网络连接名,一般为"本地连接"或"本地连接 2"等
rem IP是网卡ip地址,GW是默认网关
rem MASK是子网掩码
rem DNS1和DNS2分别是首选和备用DNS服务器
rem ****************************************************
set NIC="本地连接 3"
set IP="192.168.1.102"
set GW="192.168.1.1"
set MASK="255.255.255.0"
set DNS1="202.96.128.86"
set DNS2="202.96.134.33"
echo --------------------------------
echo 下面将把网卡%NIC%设为如下地址:                            %GW%
echo 首选DNS服务器:   %DNS2%
echo --------------------------------
echo 开始设置网卡,请稍等数秒......
netsh interface ip set address %NIC% static %IP% %MASK% %GW% 1
echo 开始设置DNS......
netsh interface ip set dns %NIC% static %DNS1% primary
netsh interface ip add dns %NIC% %DNS2%
echo 设置完毕!
pause

玩ds12c887遇到的两个问题

  自己用ds12c887做的时钟,遇到两个问题。1、电源正负极间不接104电容的话led显示会出乱,ds12c887好像对电源要求好像很高,稍微低于5V就读不了数据!2、遇到不小心接到交流5v的话,ds12c887内部就会停振,读的数据是乱的,且不走,又要重新开启!

AutoIt写的小播放器

  今天才想起以前玩过的AutoIt v3,没事看着帮助文档写的一个超简单的播放器~原来AutoIt v3也支持图型界面的,原以为像C语言一样面向过程的~

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("简单的音乐播放器", 420, 134, 252, 258)
GUISetBkColor(0x000000)
$Input1 = GUICtrlCreateInput("输入音乐文件地址", 32, 8, 273, 21)
$Button1 = GUICtrlCreateButton("播放", 24, 64, 145, 33)
$Button2 = GUICtrlCreateButton("退出", 184, 64, 129, 33)
$Slider1 = GUICtrlCreateSlider(328, 8, 89, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $daxiao = 80 , $dizhi
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button2
   Exit
  Case $Input1
   $dizhi = GUICtrlRead($Input1)
  Case $Button1
   SoundPlay($dizhi)
  Case $Slider1
   $daxiao = GUICtrlRead($Slider1)
   
 EndSwitch
SoundSetWaveVolume($daxiao)
WEnd 

其实还可以搞个停止按钮,还可以继续完善的!可惜要睡觉了~

下载地址:http://d.xdeng.cn/viewfile.php?file_id=49&file_key=imWyKZSn