找回密码
 立即注册

QQ登录

只需一步,快速开始

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

单片机4*4*4光立方,一次以16LED灯为一组的亮灭程序如何修改?

[复制链接]
跳转到指定楼层
楼主
ID:463665 发表于 2019-1-8 17:39 来自手机 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
150黑币
因为我最终只找到了4个三极管,现在想改成如图一次以16LED灯为一组的亮灭。跪求大佬帮忙改一下。我要3种以上亮灭方式要程序和仿真。以下是程序,也可以无视。



#include<reg51.h>#define uchar unsigned charunsigned char code smg[] = {0x50,0x61};void delay100ms(uchar data1ms){        uchar i,j,m;    for(i=0;i<data1ms;i++)     for(j=0;j<110;j++)            for(m=0;m<100;m++);} void disp(uchar ceng,uchar lie1,uchar lie2 ) {        delay100ms(5);        P1=ceng;        P2=lie1;        P0=lie2;  } void main(void) {         unsigned char hang,shu1;                 unsigned char code C1[][16]={         {0x07,0x0B,0x0D,0x0E,0x0E,0x0C,0x08,0x00,0x00,0x08,0x0C,0x0E,0x0C,0x08,0x00,0x00},         {0x08,0x0C,0x0E,0x0C,0x08,0x00,0x00,0x08,0x0C,0x0E,0x0C,0x08,0x00,0x00,0x08,0x0C},         {0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E},         {0x0C,0x08,0x00,0x00,0x08,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},         {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x0C,0x0E,0x0F,0x0E,0x0C,0x08,0x00},         {0x00,0x00,0x00,0x00,0x00,0x0D,0x0D,0x0D,0x05,0x09,0x09,0x09,0x0D,0x0D,0x0D,0x05},         {0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09},         {0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09}         };          unsigned char code L1[][16]={         {0xFF,0xFF,0xFF,0xFF,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x96,0x96,0x96,0x96,0x96},         {0x96,0x96,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC},         {0x01,0x03,0x07,0x0F,0x8E,0x8C,0x88,0x80,0x00,0x00,0x00,0x10,0x30,0x70,0x70,0x60},         {0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xCC,0x0F,0x33,0x66,0xCC,0xF0,0x33,0x66,0xCC},         {0x66,0x33,0xF0,0xCC,0x66,0x33,0xF0,0xCC,0xCC,0xCC,0xCC,0xCC,0x60,0x60,0x60,0x60},         {0xE8,0x74,0x32,0x11,0x00,0x06,0x66,0x60,0x60,0x60,0x00,0x00,0x06,0x66,0x60,0x60},         {0x60,0x00,0x00,0x00,0x80,0x40,0x20,0x20,0x20,0x60,0x62,0x60,0x30,0x10,0x80,0xC0},         {0x60,0x60,0x60,0x60,0x64,0x60,0x30,0x10}        //  {0x01,0x02,0x04,0x08,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//¨¢D¨|?§?¨¨             };                    unsigned char code L2[][16]={          {0xFF,0xFF,0xFF,0xFF,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x69,0x69,0x69,0x69,0x69},          {0x69,0x69,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x33,0x33,0x33,0x33,0x33,0x33,0x33},          {0x00,0x00,0x00,0x00,0x00,0x08,0x88,0xC8,0xE8,0xF0,0x71,0x31,0x11,0x10,0x04,0x06},          {0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x33,0xF0,0xCC,0x66,0x33,0x0F,0xCC,0x66,0x33},          {0x66,0xCC,0x0F,0x33,0x66,0xCC,0x0F,0x33,0x33,0x33,0x33,0x33,0x06,0x06,0x06,0x06},          {0x8E,0x47,0x23,0x11,0x00,0x00,0x00,0x06,0x06,0x06,0x66,0x60,0x00,0x00,0x06,0x06},          {0x06,0x66,0x60,0x00,0x08,0x0C,0x06,0x66,0x06,0x06,0x06,0x06,0x03,0x01,0x00,0x08},          {0x04,0x64,0x06,0x06,0x06,0x06,0x03,0x01}        //  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x80,0x40,0x20,0x10}  };         while(1)          {                  for(hang=0;hang<8;hang++)                 {                         for(shu1=0;shu1<16;shu1++)                         {                                 disp(C1[hang][shu1],L1[hang][shu1],L2[hang][shu1]);                        }                 }         } }
#ifndef __REG51_H__#define __REG51_H__/*  BYTE Register  */sfr P0   = 0x80;sfr P1   = 0x90;sfr P2   = 0xA0;sfr P3   = 0xB0;sfr PSW  = 0xD0;sfr ACC  = 0xE0;sfr B    = 0xF0;sfr SP   = 0x81;sfr DPL  = 0x82;sfr DPH  = 0x83;sfr PCON = 0x87;sfr TCON = 0x88;sfr TMOD = 0x89;sfr TL0  = 0x8A;sfr TL1  = 0x8B;sfr TH0  = 0x8C;sfr TH1  = 0x8D;sfr IE   = 0xA8;sfr IP   = 0xB8;sfr SCON = 0x98;sfr SBUF = 0x99;/*  BIT Register  *//*  PSW   */sbit CY   = 0xD7;sbit AC   = 0xD6;sbit F0   = 0xD5;sbit RS1  = 0xD4;sbit RS0  = 0xD3;sbit OV   = 0xD2;sbit P    = 0xD0;/*  TCON  */sbit TF1  = 0x8F;sbit TR1  = 0x8E;sbit TF0  = 0x8D;sbit TR0  = 0x8C;sbit IE1  = 0x8B;sbit IT1  = 0x8A;sbit IE0  = 0x89;sbit IT0  = 0x88;///*  IE   */sbit EA   = 0xAF;sbit ES   = 0xAC;sbit ET1  = 0xAB;sbit EX1  = 0xAA;sbit ET0  = 0xA9;sbit EX0  = 0xA8;/*  IP   */ sbit PS   = 0xBC;sbit PT1  = 0xBB;sbit PX1  = 0xBA;sbit PT0  = 0xB9;sbit PX0  = 0xB8;/*  P3  */sbit RD   = 0xB7;sbit WR   = 0xB6;sbit T1   = 0xB5;sbit T0   = 0xB4;sbit INT1 = 0xB3;sbit INT0 = 0xB2;sbit TXD  = 0xB1;sbit RXD  = 0xB0;/*  SCON  */sbit SM0  = 0x9F;sbit SM1  = 0x9E;sbit SM2  = 0x9D;sbit REN  = 0x9C;sbit TB8  = 0x9B;sbit RB8  = 0x9A;sbit TI   = 0x99;sbit RI   = 0x98;#endif

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

使用道具 举报

沙发
ID:123289 发表于 2019-1-9 08:55 | 只看该作者
如果你有“光立方”的概念就麻烦了,先抛弃所谓的“光立方”!
它就是64个LED灯,你用扫描显示的方式显示它们。
建立一个16*8字节的显示缓冲区,区内的每一个位对应一个灯的明暗!
写一段扫描显示程序,将显示缓冲区的数据,送到各自的LED显示。
接下来就方便了:想让哪个灯暗/亮,只要修改显示缓冲区中的对应位的0/1就可以了。
回复

使用道具 举报

板凳
ID:149389 发表于 2019-1-9 09:14 | 只看该作者
4个三极管由4个IO控制,16个IO送显示的内容,动态扫描就可以了。
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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