Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Electrical Engineering
Results will update as you type.
  • Aesthetic elements in Eagle
  • Actuators and Outputs
  • Aktuatoren (DE)
  • Analog Input
  • Analog Sensors
  • Arduino Grundlagen
  • Arduino Programmieren
  • Arduino und Processing
  • Shift Registers
  • Carvey
  • Capacitors
  • Bread Boards
  • Digitaler Input
  • Digitaler Output
  • Eagle
  • Energy Harvesting
  • H-Bridge
  • I2C (en)
  • Interrupt Service Routine
  • Mosfet Transistor
  • LED
  • PCBs Herstellen
  • Pololu Servo Controller
  • Relays as Switches
  • Pulse Width Modulation
  • RFiD
  • Schrittmotorentreiber
  • SD Karten
  • Signal Filtering
  • Transistors as Switches
  • Widerstand
  • PCB Manufacturing
  • PlatformIO
  • Lynx Smart Motion Servo
  • Electronics Basics (EN)
  • Arduino Basics (en)
  • Arduino Programming (EN)
  • Digital Outputs (en)
  • Digital Input (en)
  • Serial Communication (en)
    • Serielle Kommunikation
  • Pulse Width Modulation (en)
  • Resistors (en)
  • Arduino and P5.js
  • Arduino and ml5.js
  • Project box 2021
  • Servo Motors
  • H-Bridge (DE)
  • Networking
  • Bit Shifting
  • C++ (Arduino) Variables
  • Stepper Motor Drivers
  • Interrupt Service Routine (en)
  • Common Arduino Problems
  • Finite State Machine
  • Voltage Regulators
  • Arduino USB HID (Human Interface Devices)

/
Serial Communication (en)

Serial Communication (en)

Apr 13, 2022

German Version

Since the Arduino has a serial interface, we can also use this to see current values from the Arduino or to communicate directly with a computer. To use the serial interface, we only need to call the Serial.begin () function in setup (). Then we can use the Serial.print () or Serial.println () function to output any values. The Arduino IDE also has its own monitor. An example of serial communication looks like this:

Example "Hello World" Expand source
void setup() 
{
  Serial.begin(9600);
}
void loop() 
{
  Serial.println("Hallo Welt");
}

Serial Monitor

The corresponding baud rate must be selected in the serial monitor to display information and then the data is displayed. The monitor looks like this.

 

Call Response

This example will send back over serial everything it receives until it finds a line break symbol. 

Example "Call response" Expand source
String inData;

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
}

void loop() {
  while (Serial.available() > 0)
  {
    char recieved = Serial.read();
    inData += recieved;  // Process message when new line character is recieved
    if (recieved == '\n')
    {
            Serial.print("I got : ");
            Serial.println(inData);
            inData = ""; // Clear recieved buffer
            delay(1000);
    }
  } 
}

Further Information

Serial - The Arduino reference page


, multiple selections available,
{"serverDuration": 17, "requestCorrelationId": "678b21589103496988af447ec45c4a83"}