#include<reg52.h>
#include<intrins.h>
sbit T=P3^5;
sbit SRCLK=P3^6;
sbit SER=P3^4;
typedef unsigned char u8;
typedef unsigned int u16;
void hc595(u8 m)
{
u8 a;
SRCLK=0;
T=0;
for(a=1;a<8;a++)
{
SER=m>>7;
m<<=1;
SRCLK=1;
_nop_();
_nop_();
SRCLK=0;
}
T=1;
_nop_();
_nop_();
T=0;
}
void main()
{
hc595(0x80);
P0=0x7f;
while(1);
}
/*#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
#define aj P1
#define sg P0
sbit led=P2^0;
sbit led1=P2^7;
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
u8 code su[]={0x30,0x38,0x3f,0x3e,0x79,0x6e,0x3f,0x3e};
u8 code sm[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f};
void delay(u16 i)
{
while(i--);
}
void xunl()
{
? ? u8 i;
for(i=0;i<8;i++)
{
switch(i)
{
case (0):
a=1;b=1;c=1;break;
case (1):
a=0;b=1;c=1;break;
case (2):
a=1;b=0;c=1;break;
case (3):
a=0;b=0;c=1;break;
case (4):
a=1;b=1;c=0;break;
case (5):
a=0;b=1;c=0;break;
case (6):
a=1;b=0;c=0;break;
case (7):
a=0;b=0;c=0;break;
}
P0=sm[i];
delay(50000);
P0=0x00;
}
}
void ss()
{
u8 m;
m=0x55;
P2=m;
delay(50000);
m=0xaa;
P2=m;
delay(50000);
}
void lv()
{
u8 o;
for(o=0;o<8;o++)
{
switch(o)
{
case (0):
a=1;b=1;c=1;break;
case (1):
a=0;b=1;c=1;break;
case (2):
a=1;b=0;c=1;break;
case (3):
a=0;b=0;c=1;break;
case (4):
a=1;b=1;c=0;break;
case (5):
a=0;b=1;c=0;break;
case (6):
a=1;b=0;c=0;break;
case (7):
a=0;b=0;c=0;break;
}
P0=su[o];
delay(100);
P0=0x00;
}
}
void main()
{
u8 x;
while(1)
{
aj=0x0f;
if(aj!=0x0f)
{
aj=0x0f;
delay(1000);
if(aj!=0x0f)
{
for(x=1;x<100;x++)
{
switch(aj)
{
case 0x07:lv();break;
? case 0x0b:ss();break;
case 0x0d:xunl();break;
}
aj=0xf0;
switch(aj)
{
case 0x70:ss();break;
case 0xb0:xunl();break;
case 0xd0:lv();break;
}
}
}
}
}
}
*/
/////////////////////////////////////////////////////////////////////////////綜合程序玩耍乎
/*#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
void delay(u16 i)
{
while(i--);
}
void main()
{
u8 m;
while(1)
{
m=0x55;
P2=m;
delay(50000);
m=0xaa;
P2=m;
delay(50000);
}
}//////////////////////////////////////////////////////////////////////////////////////////led奇數(shù)偶數(shù)的換閃颇玷,彩燈閃爍。
*/
/*#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
u8 m;
#define aj P1
#define sg P0
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
u8 code sm[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(u16 i)
{
while(i--);
}
void shuzi()
{
aj=0x0f;
if(aj!=0x0f)
{
aj=0x0f;
delay(1000);
if(aj!=0x0f)
{
switch(aj)
{
case 0x07:m=0;break;
case 0x0b:m=1;break;
case 0x0d:m=2;break;
case 0x0e:m=3;break;
}
aj=0xf0;
switch(aj)
{
case 0x70:m=m;break;
case 0xb0:m=m+4;break;
case 0xd0:m=m+8;break;
case 0xe0:m=m+12;break;
}
delay(1000);
}
}
}
void main()
{
a=0;
b=0;
c=0;
while(1)
{
shuzi();
sg=sm[m];
delay(5);
}
} ///////////////////////////////////////////////////////////////////////////////////////////自定義模擬數(shù)字1-f就缆。(矩陣按鍵)
*/
/*#include<reg52.h>
#define aj P1
#define sg P0
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
typedef unsigned char u8;
typedef unsigned int u16;
u8 i;
u8 code sm[]={0x38,0x3f,0x3e,0x79,0x6e,0x3f,0x3e,0x6d,0x5b,0x3f,0x30,0x4f,0x30,0x66,0x6f,0x6f};
void delay(u16 i)
{
while(i--);
}
void bb()
{
u8 v=0; /////////////////////////////////////////////////////youcuowud
aj=0x0f;
if(aj!=0x0f)
{ //////////////////////////////////////////////////kuohaocuowul
delay(1000);
if(aj!=0x0f)
{
aj=0x0f;//////////////////////////////////////////////////////////////////youcuowu
switch(aj)
{
case 0x07:i=0;break;
case 0x0b:i=1;break;
case 0x0d:i=2;break;
case 0x0e:i=3;break;
}
aj=0xf0;
switch(aj)
{
case 0x70:i=i;break;
case 0xb0:i=i+4;break;
case 0xd0:i=i+8;break;
case 0xe0:i=i+12;break;
}
while((v<5)&&(aj!=0xf0))
{
delay(1000);
v++;
}
}
}
}
void main()
{
a=0;
b=0;
c=0;
while(1)
{
bb();
sg=sm[i];
? }
} //////////////////////////////////////////////////////////////////////////////////////////////////? ? ? ? ? ? ? ? ? 帖渠、、违崇、阿弃、诊霹、///////也就是簡單的表白一下矩陣控制數(shù)碼管第一個(love you 520131399)
*/
/*#include<reg52.h>
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
typedef unsigned char u8;
typedef unsigned int u16;
u8 code sm[]={0x30,0x38,0x3f,0x3e,0x79,0x6e,0x3f,0x3e};
void delay(u16 i)
{
while(i--);
}
void lv()
{
u8 i;
for(i=0;i<8;i++)
{
switch(i)
{
case (0):
a=1;b=1;c=1;break;
case (1):
a=0;b=1;c=1;break;
case (2):
a=1;b=0;c=1;break;
case (3):
a=0;b=0;c=1;break;
case (4):
a=1;b=1;c=0;break;
case (5):
a=0;b=1;c=0;break;
case (6):
a=1;b=0;c=0;break;
case (7):
a=0;b=0;c=0;break;
}
P0=sm[i];
delay(3);
P0=0x00;
}
}
void main()
{
while(1)
{
lv();
}
} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////這么秀 ,loveyou
*/
/*#include<reg52.h>
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
typedef unsigned char u8;
typedef unsigned int u16;
unsigned char x=1;
? unsigned char y=1;
? unsigned int z;
? u8 code sm[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f};
void delay(u16 i)
{
while(i--);
}
void main()
{
while(1)
{
for(z=0;z<250;z++)
{
P0=sm[x%10];
a=0;b=0;c=0;
delay(1);
P0=sm[x/10];
a=1;b=0;c=0;
delay(1);
P0=sm[y%10];
a=0;b=1;c=0;
delay(1); ?
P0=sm[y/10];
? a=1;b=1;c=0;
delay(1);
}
x=x+1;
if(x<99){x=1;}? ?
y=y+2;
if(y<99){y=1;}
}
}*/
///////////////////////////////////////////////////////////////////////////////////////////////////////局部變量xy的顯示
/*#include<reg52.h>
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
typedef unsigned char u8;
typedef unsigned int u16;
unsigned int x=32;
? unsigned int y=52;
? unsigned int z;
? u8 code sm[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f};
void delay(u16 i)
{
while(i--);
}
void main()
{
z=x*y;
while(1)
{
P0=sm[z/1000];
? a=1;b=1;c=0;
delay(1);
P0=sm[(z%1000)/100];
a=0;b=1;c=0;
delay(1);
P0=sm[(z%100)/10];
a=1;b=0;c=0;
delay(1);
P0=sm[z%10];
a=0;b=0;c=0;
delay(1);
}
}/////////////////////////////////////////////////////////////////////////////////////////////////////////////這是計算渣淳,用數(shù)碼管顯示結果
*/
/*#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
sbit led=P2^0;
sbit k1=P3^1;
sbit k2=P3^0;
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
u8 code sm[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f};
void delay(u16 i)
{
while(i--);
}
void qiujiu()
{
while(1)
{
u8 i;
for(i=0;i<8;i++)
{
switch(i)
{
case 0: a=1;b=1;c=1;P0=sm[5];delay(3);break;
case 1: a=0;b=1;c=1;P0=sm[0];delay(3);break;
case 2: a=1;b=0;c=1;P0=sm[5];delay(3);break;
case 3: a=1;b=1;c=1;P0=sm[5];delay(3);break;
case 4: a=0;b=1;c=1;P0=sm[0];delay(3);break;
case 5: a=1;b=0;c=1;P0=sm[5];delay(3);break;
}
}
}
}
? void ok()
{
while(1)
{
u8 i;
for(i=0;i<8;i++)
{
switch(i)
{
case 0: a=1;b=1;c=1;P0=sm[1];delay(30000);break;
case 1: a=0;b=1;c=1;P0=sm[1];delay(30000);break;
case 2: a=1;b=0;c=1;P0=sm[3];delay(30000);break;
case 3: a=1;b=1;c=1;P0=sm[5];delay(30000);break;
case 4: a=0;b=1;c=1;P0=sm[0];delay(30000);break;
case 5: a=1;b=0;c=1;P0=sm[5];delay(30000);break;
}
}
}
}
void xun()
{
u8 i;
for(i=0;i<8;i++)
{
switch(i)
{
case 0:
a=1;b=1;c=1;break;
case 1:
a=0;b=1;c=1;break;
case 2:
a=1;b=0;c=1;break;
case 3:
a=0;b=0;c=1;break;
case 4:
a=1;b=1;c=0;break;
case 5:
a=0;b=1;c=0;break;
case 6:
a=1;b=0;c=0;break;
case 7:
a=0;b=0;c=0;break;
}
P0=sm[i];
delay(50000);
P0=0x00;
if(k2==0);
delay(1000);
if(k2==0)
{
ok();
}
}
}
void main()
{
while(1)
{
if(k1==0)
{
delay(1000);
if(k1==0)
{
? u16 i;
xun();
for(i=0;i<5;i++)
{
led=0;
delay(50000);
led=1;
delay(50000);
}
qiujiu();
}
}
}
}*/ /////////////求救信號
/**********************************************************************************//////////////////////////////////////////////////////////////////////////
/*#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
sbit k1=P3^1;
sbit k2=P3^0;
sbit led=P2^0;
sbit led1=P2^7;
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
u8 code sm[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f};
void delay(u16 i)
{
while(i--);
}
void xunl()
{
? ? u8 i;
for(i=0;i<8;i++)
{
switch(i)
{
case (0):
a=1;b=1;c=1;break;
case (1):
a=0;b=1;c=1;break;
case (2):
a=1;b=0;c=1;break;
case (3):
a=0;b=0;c=1;break;
case (4):
a=1;b=1;c=0;break;
case (5):
a=0;b=1;c=0;break;
case (6):
a=1;b=0;c=0;break;
case (7):
a=0;b=0;c=0;break;
}
P0=sm[i];
delay(50000);
P0=0x00;
}
}*/
/*? void kk()
{
if(k1==0)
{
delay(1000);
if(k1==0)
{
led=~led;
}
while(!k1);
}
}
? */
/*void main()
{
while(1)
{
if(k2==0)
delay(1000);
if(k2==0)
{
u8 i;
xunl();
for(i=1;i<60;i++)
{
led=~led;
delay(5000);
led=~led;
delay(5000);
}
}
while(!k2);
}
}*/ ? ///////////////////////////////////////////////////////////////////////////閃爍著玩
/******************************************************************************//////////////////////////////////////////////////////////