cpubbs论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

LabVIEW+单片机学习套件全套教程资料下载[免费]LabVIEW论坛精华列表贴USB0816数据采集卡《LabVIEW宝典》
LabWindows/CVI论坛精华贴NET0816以太网数据采集卡RC0210远程设备授权系统 关闭关停锁定打开设备 户外分布式数据采集
NET1624低速高精度以太网数据采集卡WIFI0824SD无线WIFI网络数据采集卡脱机运行 SD存储 小尺寸微型 串口采集远程采集 安卓 手持移动采集 纪录仪
查看: 951|回复: 0

超级声光多彩灯 51单片机程序

[复制链接]
发表于 2010-6-11 16:14:02 | 显示全部楼层 |阅读模式
/*
***************************************************************************
*
*项目名称:    51单片机学习开发系统
*               
*本文件名称:super_led.c
*      
* 完成作者 : 张工(QQ:464976346)
* 当前版本 : V1.0        
* 完成日期 : 2007年3月30日
* 描    述 : 超级声光多彩灯(纯属娱乐性学习)      
****************************************************************************
*/


#include <REG52.H>   
sbit  BUZZ   = P3 ^ 3;  //蜂鸣器

/**********花样图形表(共7组)可自行添加*******************/
unsigned char code flash1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};  //从0-7
unsigned char code flash2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};  //从7-0
unsigned char code flash3[]={0x7e,0xbd,0xdb,0xe7,0xe7,0xdb,0xbd,0x7e};  //从两端开始
unsigned char code flash4[]={0xe7,0xdb,0xbd,0x7e,0x7e,0xbd,0xdb,0xe7};  //从中间开始
unsigned char code flash5[]={0xff,0x00,0xff,0x00,0xaa,0x55,0xaa,0x55};  //全闪烁和间隔闪
unsigned char code flash6[]={0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};  //从7-0
unsigned char code flash7[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};  //从0-7
/*****************延是函数********************************/
void delay(unsigned int k)     
{        
unsigned int i,j;      
for(i=0;i<k;i++)
  {     
  for(j=0;j<121;j++)     
    {;}
  }        
}        
/********************主函数********************************/
void main(void)     
{
  unsigned char temp;
   P1=0; //关闭数码管,防止数码管闪烁
        
while(1) //总循环
      
{ /**********第一组*******************/      
    for(temp=0;temp<8;temp++)  
  {P0=flash1[temp]; //查表1花样送P0口  
    delay(100);   //延时
  BUZZ=!BUZZ;   //蜂名器取反(叫停反复)
  }   
/*************第二组******************/
  for(temp=0;temp<8;temp++)  
  {P0=flash2[temp]; //查表2花样送P0口  
    delay(100);
  BUZZ=!BUZZ;}   
/*************第三组******************/
  for(temp=0;temp<8;temp++)  
  {P0=flash3[temp];   
    delay(100);
  BUZZ=!BUZZ;}   
/**************第四组*****************/
  for(temp=0;temp<8;temp++)  
  {P0=flash4[temp];   
    delay(100);
  BUZZ=!BUZZ;}   
/*************第五组******************/
  for(temp=0;temp<8;temp++)  
  {P0=flash5[temp];   
    delay(100);     //因闪烁,加大延长时间
  BUZZ=!BUZZ;
  delay(100);
  BUZZ=!BUZZ;
  delay(100);
  BUZZ=!BUZZ;
  }
/*************第六组******************/
  for(temp=0;temp<8;temp++)  
  {P0=flash6[temp];   
    delay(100);
  BUZZ=!BUZZ;}
/*************第七组******************/
  for(temp=0;temp<8;temp++)  
  {P0=flash7[temp];   
    delay(100);
  BUZZ=!BUZZ;}     
}      
}   



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

本版积分规则

Archiver|手机版|cpubbs论坛. ( 粤ICP备09171248号 )

GMT+8, 2025-4-10 10:41 , Processed in 0.452669 second(s), 6 queries , Gzip On, File On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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