找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1609|回复: 0
收起左侧

摇摇棒源程序

[复制链接]
ID:113449 发表于 2016-4-11 12:15 | 显示全部楼层 |阅读模式
#include <reg52.h>

unsigned int n=64;
unsigned char code b1[50];
unsigned int j,k,sw;
unsigned char code pv[]={
   0x00,0x12,0x00,0x22,0x7D,0xD2,0x54,0x92,0x54,0x92,0x54,0x92,0x54,0x92,0x57,0xFE,
      0x54,0x92,0x54,0x92,0x54,0x92,0x54,0xB2,0xFD,0x92,0x40,0x86,0x00,0x02,0x00,0x00,

   0x00,0x80,0x01,0x00,0x02,0x01,0x04,0x02,0x19,0x04,0x61,0xF8,0x01,0x00,0x01,0x02,
      0xC1,0x01,0x31,0x02,0x09,0xFC,0x04,0x00,0x03,0x00,0x01,0x80,0x01,0x00,0x00,0x00,

0x00,0x04,0x80,0x04,0xD0,0x15,0xA7,0xD5,0xA5,0x56,0x85,0x7C,0xFD,0x54,0x07,0xD4,
      0xD5,0x54,0xA5,0x7C,0xA5,0x56,0x87,0xD5,0xF8,0x14,0x00,0x04,0x00,0x04,0x00,0x00,

0x13,0x10,0x1D,0x18,0xF1,0x10,0x17,0xFF,0x31,0x20,0x13,0x01,0x04,0x01,0x08,0x92,
      0x31,0x12,0xC2,0x24,0x34,0x44,0x08,0x88,0x08,0x10,0x04,0x00,0x04,0x00,0x00,0x00


      };

void Delay_100Us(unsigned int tt)
{
unsigned char ii;
for(;tt>0;tt--)
    for(ii=94;ii>0;ii--);
}

void intersvr0(void) interrupt 0 using 1   
{
unsigned int i;
sw=~sw;
if (sw==0)
   {
    do {
    P0=~b1[j];P2=~b1[j];
    j=j-1;
    P2=0xff;P0=0xff;
    }   
    while(j);   
       for(i=0;i<n;i++)
     {
      P2=~pv[i*2];P0=~pv[1+i*2];
          Delay_100Us(5);
      P2=0xff;P0=0xff;
       }
     k=0;
     do
     {
     k=k+1;
     P0=~b1[k];P1=~b1[k];
     P2=0xff;P0=0xff;
     }
     while(k<=10);
}
else
{
     do{
     P0=~b1[k];P2=~b1[k];
     k=k-1;
     P2=0xff;P0=0xff;
     }        
    while(k);   
    for(i=0;i<n;i++)
      {
      P0=~pv[127-i*2];P2=~pv[126-i*2];
          Delay_100Us(5);
      P2=0xff;P0=0xff;
        }
     j=0;
     do{j=j+1;
     P0=~b1[j];P1=~b1[j];
     P2=0xff;P0=0xff;
     }
    while(j<=10);
   }
}
void main(void)
{
IT0=1;EX0=1;
EA=1;
j=50;k=50;
sw=0;
P0=0xff;P2=0xff;
while(1);
}

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表