小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
聊聊外星人
-
此回复已被删除! -
#include "stm32f10x.h"
#include "delay.h"
#include "lcd1602.h"
#include "ds18b20.h"//定义温度变量
float temp;//主函数
int main(void)
{
//初始化
delay_init(); //延时函数初始化
Lcd_Init(); //LCD1602初始化
DS18B20_Init(); //DS18B20初始化//循环 while(1) { //读取温度 temp=DS18B20_Get_Temp(); //读取温度 //显示温度 Lcd_Clear(); //清屏 Lcd_Set_Cursor(1,1); //设置光标位置 Lcd_Printf("Temp: %.2f",temp); //显示温度 delay_ms(1000); //等待1s }
}
以上为生成回答,仅供参考~
-
以下是51单片机实现键控数码管显示的代码,但有部分代码缺失了,我该怎么修改?
#include<absacc.h>
#define LEDLen 6
#define mode 0x03;
#define CAddr XBYTE[0xe100]/* 控制字地址 /
#define OUTBIT XBYTE[0xe101]/ 位控制口 /
#define CLK164 XBYTE[0xe102]/ 段控制口(接164时钟位) /
#define DAT164 XBYTE[0xe102] / 段控制口(接164数据位) /
#define IN XBYTE[0xe103] / 键盘读入口 */unsigned char LEDBuf[LEDLen]; /* 显示缓冲 /
code unsigned char LEDMAP[] = { / 八段管显示码 */
0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07,
0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71
};void Delay(unsigned char CNT)
{
unsigned char i;while (CNT-- !=0)
for (i=100; i !=0; i--);
}void DisplayLED()
{
unsigned char i, j;
unsigned char Pos;
unsigned char LED;Pos = 0x20; /* 从左边开始显示 /
for (i = 0; i < LEDLen; i++) {
OUTBIT = 0; / 关所有八段管 /
LED = LEDBuf[i];
for (j = 0; j < 8; j++) { / 送164 /
if (LED & 0x80) DAT164 = 1; else DAT164 = 0;
CLK164 = CLK164|0x02;
CLK164 = CLK164&0xfd;
LED <<= 1;
}
OUTBIT = Pos; / 显示一位八段管 /
Delay(1);
Pos >>= 1; / 显示下一位 */
}
}code unsigned char KeyTable[] = { /* 键码定义 */
0x0c, 0x08, 0x04, 0x00 ,
0x0d, 0x09, 0x05, 0x01,
0x0e, 0x0a, 0x06, 0x02 ,
0x0f, 0x0b, 0x07, 0x03 ,
0x10,0x11,0x12,0x13,0x14,
0x15,0x16,
};unsigned char TestKey()
{
OUTBIT = 0; /* 输出线置为0 /
return (~IN & 0x0f); / 读入键状态 (高四位不用) */
}unsigned char GetKey()
{
unsigned char Pos;
unsigned char i;
unsigned char k;i = 6;
Pos = 0x20; /* 找出键所在列 */
do {
OUTBIT = ~ Pos;
Pos >>= 1;
k = ~IN & 0x0f;
} while ((--i != 0) && (k == 0));/* 键值 = 列 X 4 + 行 */
if (k != 0) {
i *= 4;
if (k & 2)
i += 1;
else if (k & 4)
i += 2;
else if (k & 8 )
i += 3;OUTBIT = 0; do Delay(10); while (TestKey()); /* 等键释放 */ return(KeyTable[i]); /* 取出键码 */
} else return(0xff);
}char code dx516[3] at 0x003b;
void main()
{
unsigned char j;
CAddr = mode;
LEDBuf[0] = 0xff;
LEDBuf[1] = 0xff;
LEDBuf[2] = 0xff;
LEDBuf[3] = 0xff;
LEDBuf[4] = 0x00;
LEDBuf[5] = 0x00;while (1) {
DisplayLED();
if (TestKey()) {for (j=0;j<5;j++ ) { LEDBuf[j] = LEDBuf[j+1] ; } LEDBuf[5] = LEDMAP[GetKey() & 0x0f];
}
}
} -
要修改的话,可以根据题目要求,补充完整代码,以使其实现51单片机实现键控数码管显示的功能。具体的代码如下:
#include<absacc.h>
#define LEDLen 6
#define mode 0x03;
#define CAddr XBYTE[0xe100]/* 控制字地址 /
#define OUTBIT XBYTE[0xe101]/ 位控制口 /
#define CLK164 XBYTE[0xe102]/ 段控制口(接164时钟位) /
#define DAT164 XBYTE[0xe102] / 段控制口(接164数据位) /
#define IN XBYTE[0xe103] / 键盘读入口 /
unsigned char LEDBuf[LEDLen]; / 显示缓冲 /
code unsigned char LEDMAP[] = { / 八段管显示码 /
0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07,
0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71
};
void Delay(unsigned char CNT)
{
unsigned char i;
while (CNT-- !=0)
for (i=100; i !=0; i--);
}
void DisplayLED()
{
unsigned char i, j;
unsigned char Pos;
unsigned char LED;
Pos = 0x20; / 从左边开始显示 /
for (i = 0; i < LEDLen; i++) {
OUTBIT = 0; / 关所有八段管 /
LED = LEDBuf[i];
for (j = 0; j < 8; j++) { / 送164 /
if (LED & 0x80) DAT164 = 1; else DAT164 = 0;
CLK164 = CLK164|0x02;
CLK164 = CLK164&0xfd;
LED <<= 1;
}
OUTBIT = Pos; / 显示一位八段管 /
Delay(1);
Pos >>= 1; / 显示下一位 /
}
}
code unsigned char KeyTable[] = { / 键码定义 /
0x0c, 0x08, 0x04, 0x00 ,
0x0d, 0x09, 0x05, 0x01,
0x0e, 0x0a, 0x06, 0x02 ,
0x0f, 0x0b, 0x07, 0x03 ,
0x10,0x11,0x12,0x13,0x14,
0x15,0x16,
};
unsigned char TestKey()
{
OUTBIT = 0; / 输出线置为0 /
return (~IN & 0x0f); / 读入键状态 (高四位不用) /
}
unsigned char GetKey()
{
unsigned char Pos;
unsigned char i;
unsigned char k;
i = 6;
Pos = 0x20; / 找出键所在列 /
do {
OUTBIT = ~ Pos;
Pos >>= 1;
k = ~IN & 0x0f;
} while ((--i != 0) && (k == 0));
/ 键值 = 列 X 4 + 行 */
if (k != 0) {
i *= 4;
if
以上为生成回答,仅供参考~
-
此回复已被删除! -
此回复已被删除! -
hello 在吗
-
@小伊 controller_manager的命令格式