英文:
stm32 to arduino serial communication
问题
I am sending my adc values to an arduino board via UART.
sprintf(data," ADC1= %d ADC2= %d \n", adcData[0], adcData[1]);//working
HAL_UART_Transmit(&huart2, (uint8_t*)data, strlen(data), 1000); //working
HAL_Delay(500);
and my outputs as like this in Tera Term screen;
my arduino while loop as follows;
incomingByte = Serial.read(); // read the incoming byte:
String myString = String(incomingByte);
Serial.print(" I received:");
Serial.println(myString);
And the outputs do not match my adc values
What should I do to see my values as I sent.
英文:
I am sending my adc values to an arduino board via UART.
sprintf(data,"\f ADC1= %d ADC2= %d \r\n",adcData[0],adcData[1]);//calisiyor
HAL_UART_Transmit(&huart2,(uint8_t*)data,strlen(data),1000); //calisiyor
HAL_Delay(500);
and my outputs as like this in Tera Term screen;
my arduino while loop as follow;
incomingByte = Serial.read(); // read the incoming byte:
String myString = String(incomingByte);
Serial.print(" I received:");
Serial.println(myString);
And the outputs does not like my adc values
What should ı do to see my values as ı sent.
答案1
得分: 1
要查看您发送的值,您应该将数据中继如其发送。
int incomingByte = Serial.read(); // 读取传入的字节:
if (incomingByte >= 0) { // 如果有输入
Serial.write(incomingByte); // 打印接收到的内容
}
英文:
To see your values you sent, you should relay the data as it is sent.
int incomingByte = Serial.read(); // read the incoming byte:
if (incomingByte >= 0) { // if there is some input
Serial.write(incomingByte); // print what is received
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论