基于atmega16的16 16点阵单片机程序
程序:#include<iom16v.h>#include<macros.h>#defineucharunsignedchar#defineuintunsignedint...
程序:
# include <iom16v.h>
# include <macros.h>
# define uchar unsigned char
# define uint unsigned int
#define DS_H() PORTC |= BIT(PC7)
#define DS_L() PORTC &=~BIT(PC7)
#define clk_H() PORTC |= BIT(PC6)
#define clk_L() PORTC &=~BIT(PC6)
#define lock_H() PORTC |= BIT(PC5)
#define lock_L() PORTC &=~BIT(PC5)
uchar SBUF[32]; //定义存储段码的空间
const unsigned char sw[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F};
//汉字显示
const uchar z[]=
{
0x40,0xC0,0x40,0xFC,0x44,0xA2,0xA0,0x30,
0x18,0x14,0x12,0x11,0x90,0x50,0x38,0x10,
0x00,0x00,0x20,0x7F,0x20,0x10,0x08,0x1D,
0x05,0x02,0x04,0x0C,0x18,0x70,0x10,0x00,//*"农",0*/
0x80,0x80,0x80,0xFC,0x80,0x80,0x80,0xFE,
0x80,0x40,0x40,0x20,0x10,0x08,0x04,0x02,
0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x7F,
0x00,0x01,0x02,0x04,0x0C,0x18,0x70,0x20,//*"夫",1*/
};
/*******************************************
* 595发送一个字节数据 *
********************************************/
void send(unsigned char byte)
{
unsigned char i;
lock_L();
for (i = 0x01; i > 0; i = i<<1) //先发送低位,再发送高位
{
if((byte&i) == 0)
DS_L();
else
DS_H();
//lock_H();
clk_L();
clk_H();
}
}
void delay(uint m)
{
uint i,j;
for(i=0;i<m;i++)
{
for(j=0;j<1141;j++)
;
}
}
void main(void)
{
uint i,j;
PORTA = 0x00; //PA端口控制154
DDRA = 0x1F;
PORTC = 0x00; //PC端口控制595
DDRC = 0xF0;
while(1)
{
j=0;
for(i=0;i<16;i++)
{
send(z[j]);
send(z[j+1]);
send(z[j+32]);
send(z[j+33]);
j+=2;
delay(1);
lock_H();
PORTA = 0x10;
PORTA=sw[i];
}
}
}
显示不了啊 展开
# include <iom16v.h>
# include <macros.h>
# define uchar unsigned char
# define uint unsigned int
#define DS_H() PORTC |= BIT(PC7)
#define DS_L() PORTC &=~BIT(PC7)
#define clk_H() PORTC |= BIT(PC6)
#define clk_L() PORTC &=~BIT(PC6)
#define lock_H() PORTC |= BIT(PC5)
#define lock_L() PORTC &=~BIT(PC5)
uchar SBUF[32]; //定义存储段码的空间
const unsigned char sw[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F};
//汉字显示
const uchar z[]=
{
0x40,0xC0,0x40,0xFC,0x44,0xA2,0xA0,0x30,
0x18,0x14,0x12,0x11,0x90,0x50,0x38,0x10,
0x00,0x00,0x20,0x7F,0x20,0x10,0x08,0x1D,
0x05,0x02,0x04,0x0C,0x18,0x70,0x10,0x00,//*"农",0*/
0x80,0x80,0x80,0xFC,0x80,0x80,0x80,0xFE,
0x80,0x40,0x40,0x20,0x10,0x08,0x04,0x02,
0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x7F,
0x00,0x01,0x02,0x04,0x0C,0x18,0x70,0x20,//*"夫",1*/
};
/*******************************************
* 595发送一个字节数据 *
********************************************/
void send(unsigned char byte)
{
unsigned char i;
lock_L();
for (i = 0x01; i > 0; i = i<<1) //先发送低位,再发送高位
{
if((byte&i) == 0)
DS_L();
else
DS_H();
//lock_H();
clk_L();
clk_H();
}
}
void delay(uint m)
{
uint i,j;
for(i=0;i<m;i++)
{
for(j=0;j<1141;j++)
;
}
}
void main(void)
{
uint i,j;
PORTA = 0x00; //PA端口控制154
DDRA = 0x1F;
PORTC = 0x00; //PC端口控制595
DDRC = 0xF0;
while(1)
{
j=0;
for(i=0;i<16;i++)
{
send(z[j]);
send(z[j+1]);
send(z[j+32]);
send(z[j+33]);
j+=2;
delay(1);
lock_H();
PORTA = 0x10;
PORTA=sw[i];
}
}
}
显示不了啊 展开
2个回答
意法半导体(中国)投资有限公司
2023-06-12 广告
2023-06-12 广告
STM32是一种由意法半导体(STMicroelectronics)公司设计和生产的单片机系列,广泛用于嵌入式系统、物联网(IoT)设备、汽车电子、工业自动化等领域。STM32具有以下优点:1. 低功耗:STM32单片机通常具有较低的功耗,...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询