我了个去,传大了,话说我收到板子了,开始DIY了,但是元器件坑爹了,真是服了rd002,公母不分啊
不知道怎么上传视频先上跑马灯代码一段:
#include<STC12C5A.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit led_0= P1^0;
sbit led_1= P1^1;
sbit led_2= P1^2;
sbit led_3= P1^3;
sbit led_4= P1^4;
sbit led_5= P1^5;
sbit led_6= P1^6;
sbit led_7= P1^7;
uint tt;
void delay(uint time);
void main()
{
P1M1=0X00;
P1M0=0X00;
tt=5;
while(1)
{
P1=0X0FF;
//delay(100);
//P1=0X00 ;
// delay(100);
delay(81*tt);
led_3=0;
led_4=0;
delay(81*tt);
led_3=1;
led_4=1;
delay(81*tt);
led_2=0;
led_5=0;
led_3=0;
led_4=0;
delay(27*tt);
led_3=1;
led_4=1;
delay(27*tt);
led_3=0;
led_4=0;
delay(27*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
delay(81*tt);
led_1=0;
led_6=0;
led_2=0;
led_5=0;
led_3=0;
led_4=0;
delay(9*tt);
led_3=1;
led_4=1;
delay(9*tt);
led_3=0;
led_4=0;
delay(9*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
delay(27*tt);
led_2=0;
led_5=0;
led_3=0;
led_4=0;
delay(9*tt);
led_3=1;
led_4=1;
delay(9*tt);
led_3=0;
led_4=0;
delay(9*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
led_1=1;
led_6=1;
delay(81*tt);
P1=0;
delay(3*tt);
led_3=1;
led_4=1;
delay(3*tt);
led_3=0;
led_4=0;
delay(3*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
delay(9*tt);
led_3=0;
led_4=0;
led_2=0;
led_5=0;
delay(3*tt);
led_3=1;
led_4=1;
delay(3*tt);
led_3=0;
led_4=0;
delay(3*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
led_1=1;
led_6=1;
delay(27*tt);
led_3=0;
led_4=0;
led_2=0;
led_5=0;
led_1=0;
led_6=0;
delay(3*tt);
led_3=1;
led_4=1;
delay(3*tt);
led_3=0;
led_4=0;
delay(3*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
delay(9*tt);
led_3=0;
led_4=0;
led_2=0;
led_5=0;
delay(3*tt);
led_3=1;
led_4=1;
delay(3*tt);
led_3=0;
led_4=0;
delay(3);
P1=0XFF;
delay(81*tt);
P1=0;
delay(3*tt);
led_3=1;
led_4=1;
delay(3*tt);
led_3=0;
led_4=0;
delay(3*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
delay(9*tt);
led_3=0;
led_4=0;
led_2=0;
led_5=0;
delay(3*tt);
led_3=1;
led_4=1;
delay(3*tt);
led_3=0;
led_4=0;
delay(3*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
led_1=1;
led_6=1;
delay(27*tt);
led_3=0;
led_4=0;
led_2=0;
led_5=0;
led_1=0;
led_6=0;
delay(3*tt);
led_3=1;
led_4=1;
delay(3*tt);
led_3=0;
led_4=0;
delay(3*tt);
led_3=1;
led_4=1;
led_2=1;
led_5=1;
delay(9*tt);
led_3=0;
led_4=0;
led_2=0;
led_5=0;
delay(3*tt);
led_3=1;
led_4=1;
delay(3*tt);
led_3=0;
led_4=0;
delay(3*tt);
//P1=0XFF;
}
}
void delay(uint time)
{ uint tim1,tim2;
for(tim1=0;tim1<time;tim1++)
{
for(tim2=0;tim2<100;tim2++)
{
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
源代码(数码管与4X4按键)
#include<STC12C5A.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit wei_0= P2^0;
sbit wei_1= P2^1;
sbit wei_2= P2^2;
sbit key_o1= P3^0;
sbit key_o2= P3^1;
sbit key_o3= P3^2;
sbit key_o4= P3^3;
sbit key_i1= P3^4;
sbit key_i2= P3^5;
sbit key_i3= P3^6;
sbit key_i4= P3^7;
sbit led= P1^0;
bit only=0;
code uchar Dis_num[20]={0x3F, 0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,0x00,};
uchar wn[8];
uint tt;
uchar wi=0;
void Key_int();
void Display_Num_led();
void delay(uint time);
void main()
{
P0M1=0X00;
P0M0=0X00;
P2M1=0X00;
P2M0=0X00;
P3M1=0X00;
P3M0=0X00;
tt=100;
wn[0]=10;//A
wn[1]=11;//b
wn[2]=12;//C
wn[3]=13;//d
wn[4]=14;//E
wn[5]=15;//F
wn[6]=16;//_
wn[7]=2;
while(1)
{
Display_Num_led();
Key_int();
}
}
void Key_int()
{
P3=0X0FF;
key_o1=0;
if(key_i1==0)
{
wn[wi]=12; //S13
}
if(key_i2==0)
{
wn[wi]=8;//S9
}
if(key_i3==0)
{
wn[wi]=4;//S5
}
if(key_i4==0)
{
wn[wi]=0;//S1
}
// else;
//
P3=0X0FF;
key_o2=0;
if(key_i1==0)
{
wn[wi]=13; //S14
}
if(key_i2==0)
{
wn[wi]=9;//S10
}
if(key_i3==0)
{
wn[wi]=5;//S6
}
if(key_i4==0)
{
wn[wi]=1;//S2
}
//else;
//
P3=0X0FF;
key_o3=0;
if(key_i1==0)
{
wn[wi]=14; //S15
}
if(key_i2==0)
{
wn[wi]=10;//S11
}
if(key_i3==0)
{
wn[wi]=6;//S7
}
if(key_i4==0)
{
wn[wi]=2;//S3
}
//else;
//
P3=0X0FF;
key_o4=0;
//************************
//***one times key***
if((key_i1==only)&(key_i3==1))//&key_i3==1 防S8干扰
{only=~only;
//wn[wi]=15; //S16
if(key_i1==0)
{
++wi;
if(wi>7)
{
wi=0;
}
}
}
//***********************
if(key_i2==0)
{
wn[wi]=11;//S12
}
if(key_i3==0)
{
wn[wi]=7;//S8 *****干扰S16*******
}
if(key_i4==0)
{
wn[wi]=3;//S4
}
//else;
}
void Display_Num_led()
{
P0=Dis_num[wn[0]];
wei_0=0;
wei_1=0;
wei_2=0;
delay(tt);
P0=Dis_num[wn[1]];
wei_0=1;
wei_1=0;
wei_2=0;
delay(tt);
P0=Dis_num[wn[2]];
wei_0=0;
wei_1=1;
wei_2=0;
delay(tt);
P0=Dis_num[wn[3]];
wei_0=1;
wei_1=1;
wei_2=0;
delay(tt);
P0=Dis_num[wn[4]];
wei_0=0;
wei_1=0;
wei_2=1;
delay(tt);
P0=Dis_num[wn[5]];
wei_0=1;
wei_1=0;
wei_2=1;
delay(tt);
P0=Dis_num[wn[6]];
wei_0=0;
wei_1=1;
wei_2=1;
delay(tt);
P0=Dis_num[wn[7]];
wei_0=1;
wei_1=1;
wei_2=1;
delay(tt);
}
void delay(uint time)
{ uint tim1,tim2;
for(tim1=0;tim1<time;tim1++)
{
for(tim2=0;tim2<10;tim2++)
{
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
vscode+cmake搭建雅特力AT32L021开发环境被打赏30分 | |
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 |