i'm new to microcontrollers, i want to send numbers as numbers through UART using STM32 NUCLEOL053.
my script is:
uint8_t nums[8] = {0,1,2,3,4,5,6,7};
HAL_UART_Transmit(&huart2, nums, sizeof(nums), HAL_MAX_DELAY);
it does not work, how can i solve this? compiler tells me no error or warnings, i already know how to send numbers as string using sprintf but i need to send numbers as numbers
Try converting number in to ASCII and the call the function to transmit on UART.
uint8_t nums[8] = {0,1,2,3,4,5,6,7};
char ascii_nums[8][5];
for(int i = 0; i < 8; i++) {
itoa(nums[i], ascii_nums[i], 10); // convert the number to a string
}
Note: You need to use for
loop to transmit the numbers one after the other.