单片机中怎么把float得的变量显示在1602的液晶屏上
展开全部
float d=123.45;
int b[4] ;
void main() {
int a = d*100;
b[0] = a&0xff;
b[1] = (a>>8)&0xff;
b[2] = (a>>16)&0xff;
b[3] = (a>>24)&0xff;
printf("source:%f\n",d);
//Serial translate.
int r = b[0]+ (b[1]<<8) +(b[2]<<16) +(b[3]<<24);
printf("recoved:%f",(float)r/100);
}
int b[4] ;
void main() {
int a = d*100;
b[0] = a&0xff;
b[1] = (a>>8)&0xff;
b[2] = (a>>16)&0xff;
b[3] = (a>>24)&0xff;
printf("source:%f\n",d);
//Serial translate.
int r = b[0]+ (b[1]<<8) +(b[2]<<16) +(b[3]<<24);
printf("recoved:%f",(float)r/100);
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询