You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/04.pro/boards/portenta-c33/tutorials/user-manual/content.md
+19-1Lines changed: 19 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -704,6 +704,7 @@ The Portenta C33 supports UART communication. The pins used in the Portenta C33
704
704
705
705
Please refer to the board pinout section of the user manual to find them on the board. The built-in ([Serial](https://www.arduino.cc/reference/en/language/functions/communication/serial/)) library functions can use the UART pins.
706
706
707
+
#### UART Initialization
707
708
708
709
To begin with UART communication, you'll need to configure it first. In the `setup()` function, set the baud rate (bits per second) for UART communication:
709
710
@@ -712,12 +713,21 @@ To begin with UART communication, you'll need to configure it first. In the `set
712
713
Serial.begin(9600);
713
714
```
714
715
715
-
To read incoming data, you can use a `while()` loop to continuously check for available data with the `Serial.available()` function and read individual characters with the `Serial.read()` function. The code shown above stores the incoming characters in a String variable and processes the data when a line-ending character is received:
716
+
#### Receive Data
717
+
718
+
To read incoming data, you can use a `while()` loop to continuously check for available data with the `Serial.available()` function and read individual characters with the `Serial.read()` function.
719
+
720
+
The example sketch shown below stores incoming characters in a String variable and processes the data when a line-ending character is received:
716
721
717
722
```arduino
718
723
// Variable for storing incoming data
719
724
String incoming = "";
720
725
726
+
// Start UART communication at 9600 baud
727
+
void setup() {
728
+
Serial.begin(9600);
729
+
}
730
+
721
731
void loop() {
722
732
// Check for available data and read individual characters
723
733
while (Serial.available()) {
@@ -738,8 +748,16 @@ void loop() {
738
748
}
739
749
}
740
750
}
751
+
752
+
// Function to process the received data
753
+
void processData(String data) {
754
+
// Example: Print the received data to the Arduino IDE Serial Monitor
755
+
Serial.println("Received: " + data);
756
+
}
741
757
```
742
758
759
+
#### Transmit Data
760
+
743
761
To transmit data to another device via UART, you can use the `Serial.write()` function:
0 commit comments