单片机通过串口给控制器发送 16进制整数,控制灯带点亮
Posted 想文艺一点的程序员
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了单片机通过串口给控制器发送 16进制整数,控制灯带点亮相关的知识,希望对你有一定的参考价值。
直接发送单个字符就可以了
unsigned char a[16] = {0x5E,0x5F,0xA0,0x01,0x00,0x00,0x0C,0x04,0x00,0x01,0x02,0x00,0x00,0x00,0x5A,0xFE};
// 5E 5F A0 01 00 00 0C 05 00 01 02 00 00 00 5A FE
unsigned char b[16] = {0x5E,0x5F,0xA0,0x01,0x00,0x00,0x0C,0x05,0x00,0x01,0x02,0x00,0x00,0x00,0x5A,0xFE};
// 5E 5F A0 01 00 00 0C 06 00 01 02 00 00 00 5A FE
unsigned char c[16] = {0x5E,0x5F,0xA0,0x01,0x00,0x00,0x0C,0x06,0x00,0x01,0x02,0x00,0x00,0x00,0x5A,0xFE};
while(1)
{
for(int i = 0; i < 16; i++)
printf("%c",a[i]);
HAL_Delay(5000);
HAL_Delay(5000);
for(int i = 0; i < 16; i++)
printf("%c",b[i]);
HAL_Delay(5000);
HAL_Delay(5000);
for(int i = 0; i < 16; i++)
printf("%c",c[i]);
HAL_Delay(5000);
HAL_Delay(5000);
}
以上是关于单片机通过串口给控制器发送 16进制整数,控制灯带点亮的主要内容,如果未能解决你的问题,请参考以下文章