串口通信
int i = 0;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
//Serial.println(i++);
if(Serial.available()!=0){
Serial.println(Serial.read());
}
}
sudo busybox microcom -s 9600 /dev/ttyUSB0
-s 波特率
-t 超时退出时间 ,不加-t就是一直等待接收
echo “123456” > /dev/ttyS1
参考:
https://www.bilibili.com/video/BV1k4411J7XD?p=3