找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1700|回复: 0
打印 上一主题 下一主题
收起左侧

444光立方源程序

[复制链接]
跳转到指定楼层
楼主
ID:290483 发表于 2018-3-11 19:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include<stdio.h>
#include<reg52.h>
#define uchar unsigned char
#define uint  unsigned int
/*****************************延时函数******************************/
void Delay(uint del)
{
        uint i,j;
        for(i=0; i<del; i++)
        for(j=0; j<18270; j++)   
        ;
}
/*******************************主函数*****************************/
main()
{
/***************群体闪烁********************/
P0=0XF0;
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);
/*********************************列断续扫描**************************/
P0=0X00;
P1=0X1;
P2=0X00;
Delay(10);/*1*/
P1=0X2;
P2=0X00;
Delay(10);/*2*/
P1=0X4;
P2=0X00;
Delay(10);/*3*/
P1=0X8;
P2=0X00;
Delay(10);/*4*/
P1=0X10;
P2=0X00;
Delay(10);/*5*/
P1=0X20;
P2=0X00;
Delay(10);/*6*/
P1=0X40;
P2=0X00;
Delay(10);/*7*/
P1=0X80;
P2=0X00;
Delay(10);/*8*/
P1=0X00;
P2=0X1;
Delay(10);/*9*/
P1=0X00;
P2=0X2;
Delay(10);/*10*/
P1=0X00;
P2=0X4;
Delay(10);/*11*/
P1=0X00;
P2=0X8;
Delay(10);/*12*/
P1=0X00;
P2=0X10;
Delay(10);/*13*/
P1=0X00;
P2=0X20;
Delay(10);/*14*/
P1=0X00;
P2=0X40;
Delay(10);/*15*/
P1=0X00;
P2=0X80;
Delay(10);/*16*/
P1=0X00;
P2=0X40;
Delay(10);/*15*/
P1=0X00;
P2=0X20;
Delay(10);/*14*/
P1=0X00;
P2=0X10;
Delay(10);/*13*/
P1=0X00;
P2=0X8;
Delay(10);/*12*/
P1=0X00;
P2=0X4;
Delay(10);/*11*/
P1=0X00;
P2=0X2;
Delay(10);/*10*/
P1=0X00;
P2=0X1;
Delay(10);/*9*/
P1=0X80;
P2=0X00;
Delay(10);/*8*/
P1=0X40;
P2=0X00;
Delay(10);/*7*/
P1=0X20;
P2=0X00;
Delay(10);/*6*/
P1=0X10;
P2=0X00;
Delay(10);/*5*/
P1=0X8;
P2=0X00;
Delay(10);/*4*/
P1=0X4;
P2=0X00;
Delay(10);/*3*/
P1=0X2;
P2=0X00;
Delay(10);/*2*/
P1=0X1;
P2=0X00;
Delay(10);/*1*/


/****************************************列平面扫描*************************************/
P1=0XF;
P2=0X00;
Delay(20);/*1*/
P1=0XF0;
P2=0X00;
Delay(20);/*2*/
P1=0X00;
P2=0XF;
Delay(20);/*3*/
P1=0X00;
P2=0XF0;
Delay(20);/*4*/
P1=0X00;
P2=0XF;
Delay(20);/*3*/
P1=0XF0;
P2=0X00;
Delay(20);/*2*/
P1=0XF;
P2=0X00;
Delay(20);/*1*/
/**********************************层扫描****************************/
P0=0XFE;
P1=0XFF;
P2=0XFF;
Delay(20);/*第1层(从下到上)*/
P0=0XFD;
P1=0XFF;
P2=0XFF;
Delay(20);/*第2层(从下到上)*/
P0=0XFB;
P1=0XFF;
P2=0XFF;
Delay(20);/*第3层(从下到上)*/
P0=0XF7;
P1=0XFF;
P2=0XFF;
Delay(20);/*第4层(从下到上)*/
P0=0XFB;
P1=0XFF;
P2=0XFF;
Delay(20);/*第3层(从下到上)*/
P0=0XFD;
P1=0XFF;
P2=0XFF;
Delay(20);/*第2层(从下到上)*/
P0=0XFE;
P1=0XFF;
P2=0XFF;
Delay(20);/*第1层(从下到上)*/
/*&*******************************层平面完毕******************************/
/***************群体闪烁********************/
P0=0XF0;
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);
/*********************************列连续扫描*******************************/
P0=0X00;
P1=0X1;
P2=0X00;
Delay(10);/*1*/
P1=0X2;
P2=0X00;
Delay(10);/*2*/
P1=0X4;
P2=0X00;
Delay(10);/*3*/
P1=0X8;
P2=0X00;
Delay(10);/*4*/
P1=0X80;
P2=0X00;
Delay(10);/*8*/
P1=0X40;
P2=0X00;
Delay(10);/*7*/
P1=0X20;
P2=0X00;
Delay(10);/*6*/
P1=0X10;
P2=0X00;
Delay(10);/*5*/
P1=0X00;
P2=0X1;
Delay(10);/*9*/
P1=0X00;
P2=0X2;
Delay(10);/*10*/
P1=0X00;
P2=0X4;
Delay(10);/*11*/
P1=0X00;
P2=0X8;
Delay(10);/*12*/
P1=0X00;
P2=0X80;
Delay(10);/*16*/
P1=0X00;
P2=0X40;
Delay(10);/*15*/
P1=0X00;
P2=0X20;
Delay(10);/*14*/
P1=0X00;
P2=0X10;
Delay(10);/*13(返回开始)*/
P1=0X00;
P2=0X20;
Delay(10);/*14*/
P1=0X00;
P2=0X40;
Delay(10);/*15*/
P1=0X00;
P2=0X80;
Delay(10);/*16*/
P1=0X00;
P2=0X8;
Delay(10);/*12*/
P1=0X00;
P2=0X4;
Delay(10);/*11*/
P1=0X00;
P2=0X2;
Delay(10);/*10*/
P1=0X00;
P2=0X1;
Delay(10);/*9*/
P1=0X10;
P2=0X00;
Delay(10);/*5*/
P1=0X20;
P2=0X00;
Delay(10);/*6*/
P1=0X40;
P2=0X00;
Delay(10);/*7*/
P1=0X80;
P2=0X00;
Delay(10);/*8*/
P1=0X8;
P2=0X00;
Delay(10);/*4*/
P1=0X4;
P2=0X00;
Delay(10);/*3*/
P1=0X2;
P2=0X00;
Delay(10);/*2*/
P1=0X1;
P2=0X00;
Delay(10);/********1(完毕)****************/
/*****************逐点走*****************/
P0=0XFE;
P1=0X1;
P2=0X00;
Delay(10);/*1*/
P0=0XFE;
P1=0X2;
P2=0X00;
Delay(10);/*2*/
P0=0XFE;
P1=0X4;
P2=0X00;
Delay(10);/*3*/
P0=0XFE;
P1=0X8;
P2=0X00;
Delay(10);/*4*/
P0=0XFE;
P1=0X10;
P2=0X00;
Delay(10);/*5*/
P0=0XFE;
P1=0X20;
P2=0X00;
Delay(10);/*6*/
P0=0XFE;
P1=0X40;
P2=0X00;
Delay(10);/*7*/
P0=0XFE;
P1=0X80;
P2=0X00;
Delay(10);/*8*/
P0=0XFE;
P1=0X00;
P2=0X1;
Delay(10);/*9*/
P0=0XFE;
P1=0X00;
P2=0X2;
Delay(10);/*10*/
P0=0XFE;
P1=0X00;
P2=0X4;
Delay(10);/*11*/
P0=0XFE;
P1=0X00;
P2=0X8;
Delay(10);/*12*/
P0=0XFE;
P1=0X00;
P2=0X10;
Delay(10);/*13*/
P0=0XFE;
P1=0X00;
P2=0X20;
Delay(10);/*14*/
P0=0XFE;
P1=0X00;
P2=0X40;
Delay(10);/*15*/
P0=0XFE;
P1=0X00;
P2=0X80;
Delay(10);/*16*/
/*****************正方形放大缩小*********************/
P0=0XFC;
P1=0X00;
P2=0XCC;
Delay(100);/*小正方形*/
P0=0XF8;
P1=0XE0;
P2=0XEE;/*放大一倍*/
Delay(100);
P0=0XF0;
P1=0XFF;
P2=0XFF;
Delay(100);/*再次放大(全亮)*/
P0=0XF8;
P1=0XE0;
P2=0XEE;/*放大一倍*/
Delay(100);
P0=0XFC;
P1=0X00;
P2=0XCC;/*小正方形*/
Delay(200);
/***************群体闪烁********************/
P0=0XF0;
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);
P1=0X00;
P2=0X00;
Delay(10);
P1=0XFF;
P2=0XFF;
Delay(10);

/****************贪吃蛇******************/
P0=0XF7;
P1=0XE;
P2=0X80;
Delay(50);
P1=0X7;
P2=0X80;
Delay(50);
P1=0X13;
P2=0X80;
Delay(50);
P1=0X11;
P2=0X81;
Delay(50);
P1=0X10;
P2=0X91;
Delay(50);
P1=0X00;
P2=0XB1;
Delay(50);
P1=0X00;
P2=0XF0;
Delay(50);
}

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏4 分享淘帖 顶1 踩
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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