Serial Input Basics - updated

Updated Version

Please note that this is a revised version of the advice in this earlier Thread which has become very long. As far as possible I have kept the code examples identical or simplifed them slightly. It should not be necessary to refer to the older Thread, but feel free to do so.

Contents

The following sections are in this Tutorial

  • Introduction

  • Serial data is slow by Arduino standards

  • Example 1 - Receiving single characters

  • Why code is organized into functions

  • Example 2 - Receiving several characters from the Serial Monitor

  • Example 3 - A more complete system

  • How many characters can be received?

  • Things that are not used in the examples

  • serialEvent()

  • Clearing the input buffer

  • Receiving numbers rather than text

  • Example 4 - Receiving a single number from the Serial Monitor

  • Example 5 - Receiving and parsing several pieces of data

  • Binary data

  • Example 6 - Program to receive binary data

Please note that the tutorial continues into the next 2 Posts

Introduction

Newcomers often seem to have difficulty with the process of receiving Serial data on the Arduino - especially when they need to receive more than a single character. The fact that there are 18 different functions listed on the Serial reference page probably does not help

You could write a small book and still not cover every possible situation for data reception. Rather than write pages and pages that few would read I thought it would be more useful to present a few examples which will probably cover all of a newcomer's needs. And when you understand these examples you should be able to figure out solutions for other strange cases.

Almost all serial input data can be covered by three simple situations

A - when only a single character is required
B - when only simple manual input from the Serial Monitor is required
C - other

Serial data is slow by Arduino standards

When anything sends serial data to the Arduino it arrives into the Arduino input buffer at a speed set by the baud rate. At 9600 baud about 960 characters arrive per second which means there is a gap of just over 1 millisecond between characters. The Arduino can do a lot in 1 millisecond so the code that follows is designed not to waste time waiting when there is nothing in the input buffer even if all of the data has not yet arrived. Even at 115200 baud there is still 86 microseconds or 1376 Arduino instructions between characters.

And because data arrives relatively slowly it is easy for the Arduino to empty the serial input buffer even though all of the data has not yet arrived. Many newcomers make the mistake of assuming that something like while (Serial.available() > 0) { will pick up all the data that is sent. But it is far more likely that the WHILE will empty the buffer even though only part of the data has arrived.

Example 1 - Receiving single characters

In very many cases all that is needed is to send a single character to the Arduino. Between the upper and lower case letters and the numeric characters there are 62 options. For example you could use 'F' for forward, 'R' for reverse and 'S' for stop.

Code to receive a single character is as simple as this

// Example 1 - Receiving single characters

char receivedChar;
boolean newData = false;

void setup() {
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvOneChar();
    showNewData();
}

void recvOneChar() {
    if (Serial.available() > 0) {
        receivedChar = Serial.read();
        newData = true;
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChar);
        newData = false;
    }
}

Why code is organized into functions

Even though this example is short and simple I have deliberately put the code to receive the character into a separate function called recvOneChar() as that makes it simple to add it into any other program. I also have the code for showing the character in the function showNewData() because you can change that to do whatever you want without upsetting the rest of the code.

If you wish to use the code from any of the examples in your own program I suggest that you just copy the complete functions from the relevant example and create the necessary global variables at the top of your own program.

Example 2 - Receiving several characters from the Serial Monitor

If you need to receive more than a single character from the Serial Monitor (perhaps you want to input people's names) you will need some method of letting the Arduino know when it has received the full message. The simplest way to do this is to set the line-ending to newline.

This is done with the box at the bottom of the Serial Monitor window. You can choose between "No line ending", "Newline", "Carriage return" and "Both NL and CR". When you select the "Newline" option a new-line character ('\n') is added at the end of everything you send.

// Example 2 - Receive with an end-marker

const byte numChars = 32;
char receivedChars[numChars];   // an array to store the received data

boolean newData = false;

void setup() {
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvWithEndMarker();
    showNewData();
}

void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    
    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}

This version of the program reads all the characters into an array until it detects the Newline character as an end marker.

Continued in next Post

...R

43 Likes
Is there a better way to communicate via serial?
Receive input via serial
How to read String From Serial Monitor WITHOUT delay?
A thread for serious bugs in the new forum
Testing links in the new forum [Reported issue]
Two way Serial Communication
Real communication between arduino and NodeMCU
Reading multiple values from serial at a time
Data in serial comm going more than expected
does anyone know how to combine data from serial software serial?
I want take data upto 10 kb from one device serially and send that data to pc serially using arduino is it possible?
Serial Read/Input Individual Characters
Connect spliced USB cable directly to Arduino
Trying to Read Specific Serial Inputs
Reading RS232 data with arduino uno
Problems with serial.read()
Error conversion from 'char' to 'String' is ambiguous
(char)Serial.read() outputs ⸮
Bad Serial Data From SoftwareSerial
Arduino Bluetooth Control FastLED
Error setting up serial communication
Engine Dyno Projekt
Sd card reading char of string from serial port and writing in shift register
Serial readbytes behaviour
Issues using if else if statements in terminal
Durchflusssensor mit Bedingung / #Anfänger#
HC-05 and JSON data
Can't get UART connection between two ESP32s (solved)
How to transmit telemetry data from Arduino plane to pc
Two MCUs, one SD card (SPI +Serial?)
Arduino UART Packet Handling
Servo motor turns to max angle & initial angle when using serial
How can i connect another Arduino if I'm using FASTLED?
Reading Gibberish from Serial2 on Serial
[SOLVED]Slow response via Serial Communication
How to convert HEX number in DEC
How to read/write to an array from serial?
Pre paid energy meter with Arduino and GSM sim 800C recharge and "pulsein" counting problem
Bluetooth + Serial Monitor = Trouble?
Voltage resetting with MCP4725
How do I know that the data received from serial is valid?
Help me figure out the code please
Need to control 37 digital I/O pins with different states at once
Leitungsschirmung
Problem with Arduino Delay Reading From Serial Port
Need help with reading a string
Need help with reading a string
Arduino Serial.read question
Issue with Serial.Read and Serial.parseInt using L293D shield and Drone Motor
Glitches in HC12 communication
Glitches in HC12 communication
How to use serial to communicate with a host win32 program
Sending a value between Arduinos using HC-05 Bluetooth modules
Help with Serial Behaviour
Function intended to read entire serial input into a char array reads just one char at the time
Decode serial port output of MPU6050 sensor data with a second arduino
How to copy part of a char array into an otner char array
Half duplex nrf24l01
Hardware serial communication
Converting char to int
Switch Case ipv If Then
Combining code (servo motor & l298N driver)
Issue to get updated values using Serial communication
If sentence does not detect a string
Using serial communication
Serial.readString() not reading
Guidance Request on Basic Serial Communications to PC
Why is my serial data ending to soon
HC-05 multiple receiving data
Bluetooth timings
Convert serial read char to HEX and write to EEPROM
LED code and receiving Serial seem to clash
Serielle Kommunikation zwischen 2 Arduino
Code improvement and eliminate String use
Einfachste Übertragung einer Zahl (0-9) von Nano auf Uno?
Hilfe bei Code Erstellung anhand eines Ablaufdiagramms
Serial comunication tussen uno en mega
Please i need some helpon this
EEP-file Upload, Bootloader Alternatives
2 Issues with my LCD
Wrong CSV values from SD card
Serial.available() gibt unerwartete Anzahl zurück
Mega 2560 serial read and write problem
ESP NOW D1 mini receiver acts on different data
Arduino serial monitor control LEDS
Zwei HC-05 Bluetooth Module schneller kommunizieren lassen
Persisting latency between arduino and pyserial on windows 10 pro
Comm between ESP32-CAM and Arduino Uno/Mega
Trouble porting LoRa+Nano project to Attiny85 (Serial Comm Issue?)
Varying values from sensor between Arduino and Processing?
Controlling LED chain via Bluetooth | indoor bouldering App
Substring funktioniert nicht
Substring funktioniert nicht
How a character is converted to a string. How to read data such as Esp32, bluetooth low energy Serial.readString ()
CH376S connectivity issue with ESP8266
Change via rs232 (pc to arduino) my network name with char* format and password with uint32_t format
How to send and receive struct data packet over serial
Serial question, sending sensor data from MicroView/Uno to Uno
Hi Speed serial data transfer PC to Arduino via USB2
Servo resets to 0 after serial input
How to pass a String to a Char Pointer
5x 7 Segment-Anzeigen ansteuern (Wörter schreiben)
Parsing numbers from RS232
SerialTransfer between two Arduinos not working
Request Serial data
How to receive serial characters stream
Serial read twice doesn't work
Reading specific data from arduino serial monitor
Serial communication changes my frequency output
Mega 2560 to MKR wifi1010 communication
Serial communication NodeMcu&Atmega
UART Serial Communication Between UNO and Leonardo for Controlling Servo With Potentiometer
Write and Read to EEPROM with Serial Monitor
Batterie Shunt mit Datenlogger
How to divided 1 string in 1 smaller string and 4 integers?
Multiple Serial Transfer Data
About Bluetooth data received
Why does the variable `char c`produce a long string of characters?
Via de serial monitor een command geven om de een methode te stoppen
Receiving multiple int from serial SOLVED
RS485 using Serial.available() only scans one character
Serielle Kommunikation (done)
Why is my code not returning all of the serial data being given to it?
Bluetooth data trans problem
Wireless Transmission of PWM Signals
HC-05 two way communication serial or I2C?
Why is array not printing?
ESP-01 und Arduino MEGA kommunizieren lassen
Using C# Winforms to control 2 servos, delay issues
PROBLEM reading from serial monitor
How do I use RX and TX for arduino nano bbe?
Mega 4 SPI channels
Serial event example revised
Problem with instruction Serial.readStringUntil(char)
UART Communication Issue: Arduino Uno to Nano 33 BLE Sense Rev 2
New and need help with my code
Arduino read Byte Array from Java application
ESP32 Cam Serial Data Transfer to Arduino Uno
Can you do this without changing the SoftwareSerial buffer size?
Saving Simulink data in Ardunio Variables
Can you do this without changing the SoftwareSerial buffer size?
UART buffer size -- is it 63 or 64?
Servos not working with serial
How to convert a string in a decimal value "12345" to 12345
ESP32 Uart troubleshooting
ERROR compiling for board generic ESP8266 (Arduino mega))
Serial communication with Python - beginner qestion
How to request input from the Serial Monitor
Decoding serial data from module
Having trouble sending and reading 2 bytes from Serial Port
Domotica in home
How we Read 31 bytes Data in Serial Communication
Saving 4 different integers from serial communication
Arduino Mega - sending commands via RS232
Help controlling a light from PC
Code entering if statement when it shouldn't
Correpted Data in serial communication
toInt() is not working properly
I'm looking for the StreamSend.h library for use in Arduino/ESP8266 serial communications using struct
Splitting a char with a deliminator
How to parse this data from external devices
Wrong servo spinning
SD errorCode: 0X30,0XFF
How to avoid delay(1) in reading serial data
Decode 8 bytes hex
Sending Code to Stepper Motors
Serial Communication with Arduino to control Relays --- Code not entering 'If' statement
Serielle Schnittstelle HEX
UART receiving problem
Get command from serial
Store txt as variable
Pump not turning on when expect, using bluetooth and parsing data
'Command' was not declared in this scope
Delay when comparing value received via serial
Stepper motor not responding to Arduino Gcodes
Communicating two Arduino Nano using SoftwareSerial
Help with RS232 timing needed
Serial.read to array writes everything in one index
Arduino hängt sich auf - Probleme mit Serial und I2C?
Communication problem
How to maintain original data using strchr
ESP32 Bluetooth help
Issues with DigiPot GUI slider with MAX 5487
Receiving Byte Array over serial
Serial Port Interrupts?
RS485 using CRC16 telegram termination
Reading 3 bytes from HC-05 Bluetooth Module
From robot to phone via Bluetooth using Bluetooth electronics
Atmega 328p -hangs
Serial Port Interrupts?
How to return value using the switch in arduino iot dashboard
Arduino and RS485
Nano BLE serial send to regular nano wont work
Python Code to move the actuator Forward and Backward code not working - please help
I want help serial communication between arduino and python
Trouble porting LoRa+Nano project to Attiny85 (Serial Comm Issue?)
Enviar datos desde el monitor serial a Arduino
Sending 16-bit integer values via Bluetooth
I don't know how to read an entire word in the serial
I2C Kommunikation gestört
Reading and using a value from the serial monitor
Ethernet client program question
Serial input ang receive int question
Sending floats over serial question
Serial data only displayed if HC12 master has a 2 second delay
How to use EEPROM with servo?
How to use EEPROM with servo?
Serial Communication UART for SmartCar Control via ESP32
ISO C++ forbids comparison between pointer and integer
How to read String From Serial Monitor WITHOUT delay?
Different behavior between nano and nano every
Error in compiling esp32 in arduino ide
Issue Receiving Full Data from PLC in Arduino Project with 7-Segment Display
Why is array not printing?
Arduino Uno with RS485 TTL module
How do i detect input from a laptop/desktop computer , such as a line or string of text?
Help with BT Data to Text
Continues check a value
Python communication problem
Bluefruit LE UART Friend on Arduino Uno
I want my Arduino UNO to read data from a .txt file
Reading RS232 with MAX3232 module
Set Multiple variables using Serial Monitor
Trouble porting LoRa+Nano project to Attiny85 (Serial Comm Issue?)
Retrieving substrings of unknown size string
Receive type:doubles with ESP32 Bluetooth
Slow serial communication
Simplifying harder statements to easier more understandable code
Serial monitor and integers
Kryptische Zeichen bei Seriellverbindung (Arduino Nano)
Serial1 Communication Issues
Second board isn't receiving serial data
Serial.read Data to An Array
Use an old PC as Arduino
Esp32 zwei i2c Schnittstellen nutzen
Send data from MATLAB to Arduino Uno via serial communication
Simple for you guys I´m sure
How to call different "Serial" in the same function ?
Digital read and bluetooth read
Reading data from joystick through bluetooth HC-05 module
Need help setting up Arduino with Bluetooth
Transmitter and receiver with HC12
Is this programma correct
Fading LEDs on and off to a brightness specified via Serial
Serial Bağlantı max. kaç karakter yazabilir?
Problem i2c with while loop
BT05 Bluetooth Module
Arduino with Bluetooth problem
User defined EEPROM
How to attach two codes? help me please
Convert string with data to 3 values
Arduino Mega Tx Rx auf digtiale Pins ändern
Rylr896 lora module
Problem with Serial communications
Syncronize Serial Comms
SoftwareSerial is hard
Getting Error: invalid conversion from 'char' to 'const char*'
Command from serial not working
If I send a long string to arduino by serial communication, how many characters can the buffer hold?
If I send a long string to arduino by serial communication, how many characters can the buffer hold?
Arduino serial esp01
RS485 ESP32 half-duplex communication
Interfacing the RS232 to TTL with Raspberry pi pico using arduinoIDE
Problem on multiple use of serial.available() in single void loop()
Serial monitor and EEPROM
What seems like it should be simple but I don't understand-serial communication between arduinos
Upload data to arduino without re-loading the program?
Serial.read() getting random characters from exact same input
Sending data from OPTA to UNO R4
Sending more than one digit with HC06
Sending more than one digit with HC06
Arduino serial communication with computer
Issue with Serial.read()
The Bluetooth receive or code error
Using multiple UART-s on MEGA at same time
Serial issues in my codes
Extract data from HTML
Servos Return to 0 after entering variable
Conversion via Rx Tx to LCD
Issues with BluetoothSerial.h library and string comparison
Transferring Data of Sensors from one Arduino to another Arduino/Controllino
How to set up these 2 sketches in 1 (for hc12)
Tractor intermittent wiper motor control with added DFRobot Intelligent Rain Detection Module
Bluetooth Servo Motor Not Properly Working
Arduino Nano - NodeMCU Serial Communication - Issues
Transfer stored integer by using software serial
Best practice for splitting strings
App controls motors, not servos
Interfacing the RS232 to TTL with Raspberry pi pico using arduinoIDE
Arduino Nano Serial Communication with Pure Data to control Neopixel
To receive Float data from Arduino Mega to Node MCU
How do I increase the serial receive buffer
[Serial issue] Exact same code wont work on Mega, but works with Uno
Problem sending a double over SoftwareSerial communication using Ebyte220 900TD LoRa modules
Arduino and HC-05 Communication Issue
Read Csv and assign Varriable
Read most recent item in Serial buffer
2 sets of Arduino-Bluetooth HC-05 + Ultrasonic sensor HC-SR04
Neo6mv2 + NeoGPS + CA 7 segment Display Speedometer code streamlining
20x4 lcd displaying text from BT serial
Emfpangen von Befehlen über Seriellen Monitor
With the arduino nano how can I read an input at the same time that I read the text messages of the sim800L
Due Serial Communication & Relay control
Help with stepper motor setup for V plotter
Input Number Check
DigitalWrite Bluetooth command
Reading values from bluetooth with parseInt
Serial communication, send a lot informations
How can my robot do an action for a time an x number of time
Transfer data from ESP32 to Arduino Uno using UART
Appropriate protocol to communicate with mobile device?
Some problem with setting PWM (Arduino nano)
Very long string formating
How to convert a substring to uint8_t or int8_t
Spike elimination parsing data
Distinguish Data On Serial Communication
Bluetooth sending and receiving two Bytenumber?
Oxygen Sensor Programming with Arduino UNO R3
Softwareserial binär daten lesen
Erstes Programm, läuft - nach ca. 1-2 Std. gibts falsche Werte
Serial read / write Best Practices
Arduino and Leap Motion - Black Screen
IR Remote LED Control Question
Making 2 boards communicate in sync with each other over Bluetooth
Connect two HC-05 modules to controll DC Motors with joysticks
High Speed Serial Communication Not Working
Multiple RFID With UART
Probleme on char to float conversion
Temperatursensor, Arduino, Messumformer
Best structure to use for sending multiple variables between a phone and ESP32 via Bluetooth
Trouble with Serial event
Transfer data from ESP32 to Arduino Uno using UART
Buffers and arrays for serial data - basic help needed to get started
How Converd string to char
Data to Website with Serial
ISO C++ forbids comparison between pointer and integer
Reading Integers from Serial Communication
Unable to read/write serial port multiple times
Need to make my serial command array work more efficiently and reliably
Serial Bluetooth and receiving/ storing strings
Unable to store keypad entries
Efficient way for reading input commands
LED will not turn on. Please send help
Connect two HC-05 modules to controll DC Motors with joysticks
Could not output my number
Help getting Teensy 4.1 to read commands consistently from MATLAB?
Cannot Get Info From Two Modules
Changing variable values from pc via serial
Hc05 bluetooth module not working, not receiving values
How would I read strings to turn the project off and on?
Hardware Serial Port Communication
[SOLVED]Red message while compiling
Privacy policy changes regarding inactive users
Basic DigitalWriteSerial or AnalogWriteSerial arduino example? Solved: Communications/PhysicalPixel.ino
Arduino serial comms
Nextion display and arduino uno serial issue
4 stepper and 2 servo with CNC shield
Is there better way to remove '\n' character from Serial Buffer while executing Serial.readBytesUntil() function?
Using the monitor input to trigger a function
Serial communication between Esp32 and Arduino one
Receive StartSign (Hex 1E) + integer+ CR (Hex 0D) into arduino
Can I send multiple data in one package?
How to send data from Arduino Nano 33 BLE to Arduino Nano?
Manchester decoding 200hz
Serial.read and Serial.parseint as an alternative to String and char manipulation?
RS485 mit Blankem MAX485 Chip
Using relays to operate a 12v Linear actuator with time delays
Value in Serial arduino
Controlling multiple servos independently from serial monitor inputs
Dividing UART message into two variables
Why is my transmitted information all garbled up using 2 UART NRF24L01 module?
Sending data by serial monitor for angle control of a stepper motor with gearbox
Arduino & vb6 pc
Auslesen Serial Port Hex Daten
What the hell about serial?!?!
Reading Serial Input from Serial Monitor, reports bad values
Serial.parseInt() not working as I expected
Uart RX und TX Übertragung. Hilfe benötigt
Serial buffer extension for SAMD21 feather m0 express board
Seriell Integer übertragen
2 Arduinos communicating through digital pins & interrupts
Trouble using Modbus Protocol for RS485-based Sensor
How to extract a subarray and convert it into float?
Sending JSON over serial
Finite state machine on arduino with Serial Interrupts
I want to interface with Chinese Temperature & Humidity Module TTL level Serial Port with Arduino
Arduino two Bluetooth HC-05, receiving different values on the receiver
Help parsing coordinates from Serial
Verifying a string within an if statement
Using more RS485 boards connected to one Arduino board
How to Identify GPS Coordinates as a String to be Sent to Cloud
Hardware Serial, how the data come to buffer?
Using ESP32_FAST_PWM and Serial Bluetooth to control electric skateboard motor
Nextion display not responding
Using data from a serial packet
Python application with C Arduino system
How to get certain output from multiple outputs in the serial monitoring?
Getting a UART to work
Identifying the last character in char to store that in array
Is there an interrupt that fires when serialAvailable() goes true?
Measure sensordata 500 times then calculate average value
Sending data over Serial communication has 1 second delay
Seperating serial data
Reading only on digit out of the Serial buffer
Is there a way to import a .csv file on Arduino created on MATLAB?
Encoder limit not stopping motor
Converting Char Array[] into int
Communication Between Linux and Arduino
Cant get serial working right
Very strange syntax?
Serial.available bugged when Serial.print'ing while data are incoming
Need Help with controlling a motor and servo independently using Serial.read()
I want the led to be on continuously on for 10 seconds after serial input is 1
Need Help with controlling a motor and servo independently using Serial.read()
"exit status 1 no matching function for call to 'Servo::attach()'"
SERIAL-BT data not showing correct on serial montor
digitalWrite doesn't work sometimes
Tm1637 GPS clock
Error reading uint8 values while trying to read serial information from a scale for mass-based flow calculation
Communicating between ESP32 (from Sparkfun type c) and Arduino Mega2560
Upload new data on the spot without PC/BT/WIFI
Reading a 32bit integer from Serial port
Arduino mega with esp32
Why does the button work with delay?
Arduino to arduino serial communication with sensor and LCD
Control led at pin 13 of Arduino 2 through serial communication from Arduino 1
How declare char type array
How declare char type array
How to get rid of this blocking delay
Menu Suggestion for PID controller
How fast in serial?
How to Read string on serial event
Serial Communication without USB
Bluetooth between Arduino boards does not work
Handling data from an RS232 scale
Please tell me how to convert from HEX to characters
Local Mosquito broker and ESP32 does not connect
Serial connection between ESP-32 and Arduino UNO
Selriell lesen unterscheiden
Two way serial communication between two boards
How to get serial timeout in microseconds in python
Max bytes in one Serial.write
Couple 2 A.mega2560 : ok ?
Moving from Serial.readstring() to Serial.read() for strings
Daten aus NMEA Datentelegramm extrahieren
Serial Communication between ArduinoIDE and Simulink for controlling motor
How to establish a bi-directional binary communication system using two arduinos
Share tips you have come across
Controling relay or valve pin with serial input
LED blinking when clicking at one button
Arduino interface with c#
How to read binary correctly?
Using the Serial Monitor with Serial.read() and Serial.parseInt() in the same code
Serial data confusion
Read messagge with Sim800L v.2
Delay in timer interrupt
Data in Serial Monitor Displays Incorrectly
Not able to print the entire string
Pi => Nano => MAX7219
Joystick serial communication
Problem with user input
Reading Data from Keyence Laser Micrometer to Arduino
Using arduino with weight scales
How straight forward would it be to send values between a pc and multiple arduino pro micros
Arduino Zero Tx and Rx
How do I read the UART communication protocol from a datasheet?
Confusion about serial.read()
Why does Serial.available() not return 0 without entering any data into the Serial Monitor when the buad rate is higher than 9600?
Serial Port not working well
Send recive data separated by comma
HC05 Bluetooth Car
Stepper Motor control with sensor interrupts
Read specific lines from txt file
How to I convert multiple lines of serial read from the UNO to ESP32 via floats?
Stcmp abfrage geht nicht
Best first 5 topics to read to reach Trust Level 1?
Serielle Datenübernahme -> digit. Stromzähler
Reverse questionmarks on serialmonitor output
Serial Kommunikation Autoterm Heizung
How do I increment a global variable in a function?
Several seconds of lag on serial processing
I can enter if but not execute statements inside
Stop the rotation of stepper motor when the key is pressed
Serial between two arduino UNO
Receiving data problem via bluetooth communication
Getting this error even after pressing boot button on esp
How can I use serial communication between my esp32 cam once it has detected an object to ask a UNO r3 to do something?
Array Error Message
Detect when a certain string was received in Serial
Anyone knows how to change this to work with 3 integers instead?
Separeted commands
Dwin HMI Project
Obstacle avoiding car not working properly
Serial communication speed issue? how to delay buffer
Связь по uart на Arduino Mega 2560 и Lolin Wemos d1 r1
Arduino IDE Serial Monitor
Serial data input handling questions
Ultra precise 29.9Hz ApertureWheel (with control and display)
How do I read the UART communication protocol from a datasheet?
Fatal error in script
Parsing a comma delimited string from serial monitor (AtMega2560 wifi built-in)
Expected HTML GET response only with cookie statement; And I can't get data for my website
How to trigger actions to even hours?
LED circuit won’t function
Error: ISO C++ forbids comparison between pointer and integer [-fpermissive] ESP8266 NodemCu
Serial.read() issue
Need help for reading values
Split string datetime from bluetooth read
UART constraint between ESP32 and Arduino UNO
Store data from a digital balance (RS232) in an SD card
Willing to pay for a code
GEt the chipper Data
How to output from UNO R3 commands from a C# application ?
Vulstand tank met Lcd scherm op afstand
Serial communication timing issue
Arduino UNO + Modbus RTU RS485 + wind sensor
How to output from UNO R3 commands from a C# application ?
ESP-01 ESP8266WiFi module Connect to Arduino Mega
UDP Data to Variables
How to receive multiple variables from the serial port and then convert them into a float?
Rotary encoder and tm1637
Send the asci command to get the sensor value
Problem in converting the MSPv2 to get flow X, flow Y, and distance from module "optical flow lidar sensor"
Data Input from Serial Monitor to Control Stepper Motor with Arduino Uno
Sorting data coming in from the serial port
Serial Monitor Not Printing What it Should - Nano
Sending Serial data from UNO to NodeMCU
While loop refusues to stop
How to send data between Unos
How to save string from serial into EEPROM
Parsing Multiple Data Segments on Bluetooth Using readStringUntil
How to read HLK-LD303 24ghz sensor data using arduino
ARDUINO UNO for robotic arm
NPK Sensor: How to convert hex to dec?
Arduino Mega 2560 Serial Communication to ESP8266(NodemCU)
Dezimalzahlen per Serial übertragen
Help with Best practice for sending multiple serial strings constantly
HC12 receives weird stuff
Communication between Ardunio Uno and ESP32 other than I2C
Benötige Hilfe: MAX7219 soll Text von Serieller Eingabe anzeigen
Reading RS232 Serial Data from a Pulse Ox
Need a code because I'm a very newbie in arduino programming
Serial communication not working as expected
Serial data input handling questions
Converting Decimal to Binary
I'm getting serial Rx overruns but I thought I was doing it right!
What is the equivalent of "cin >>" in arduino Serial Monitor
Why does my Serial Monitor print per character to the next line?
Arduino GSM SIM900 receiving text and then storing value as a variable in code
Software serial - making it wait
Problem with reading serial string
HC-12 wireless 2 second Latency
Hc 12 changing servomotor controll
Why does entering serial data lag my code
Im trying to define one letter as another
Error while receiving RS232 data
Lights not working
About Serial.available() and if Commands
Sending hexa decimal values through serial port of Arduino
Trouble with Serial.readStringUntil('\n')
How to get mit app inventor to send 3 variables
Switch case is always defaulting in TinkerCAD circuit editor
Sending serial data via batch file triggered by a stream deck to be received by Arduino Uno Rev3
Wokwi Simulations for Arduino Built-In Examples
Problem with Code
Connecting multiple arduino's to a central unit
Serial.readString();
Sent data from UNO to mega2560
Running a neural network with matlab and arduino
.exe file to change values in code?
Serial data Transfer
Receiving serial with null character
Encryption over serial: Linux server to UNO
Get string from serial port with timeout
Software Serial Probleme
Byte array to char !
Change stop bit in Serial.begin
Arduino Mega Freezing upon high serial load
How to establish a serial communication between an ESP32 s3 dev kit c module and Arduino board
Sending Serial Command from one Arduino to Another
How would I write code to receive data from MAX Msp?
ESP32 printing ASCII numbers instead of normal human-readable text
How can I connect nextion displays to multiple megas
Can't seem to reliably receive data across serial ports
Bluetooth command terminator code problem
I am making a project and have two codes and need to combine them
Serial port blocking itself?
Confused about reading serial and general handling of it
How do I read characters into an array from the serial monitor?
Serial Communication Help
Joystick conrolling servos over HC-05
Works fine at 115200 but does not at 9600 baud
Joystick conrolling servos over HC-05
Any way to send message from ESP32 to Arduino UNO?
More correct way to send and receive data over WiFi using HTTP between ESP8266
Missing Keyboard.h
Output polarity control for addressable LEDs
Using 2 types of bluetooth commands
Arduino Mega + DMX + Esp01
Question about sending serial data and data types (bytes vs string)
Smart Glasses for the Blind: Reading ESP32 Serial Port Information
Code processing at slow speed
How to empty buffer 63 byte limit
Loosing data when reading over serial
How to send serial keyboard data from USB Host shield to another arduino board
Arduino SBUS lichtmodule
Combining Stepper Movement and Dial Indicator Readout
Reading text from serial and compare the input always fails
If I use one serial port it doesn't work unless it also uses software serial
Serial Communication with Stepper Motor Project Guidance
RS485 mit Blankem MAX485 Chip
Cant get strtok() to work for me [SOLVED]
Serielle Schnittstelle - Hilfe für Anfänger
Assistance with network problem please [solved]
Converting 2-digit number into byte
Batteriespannung mit Attiny85 auslesen und via. HC12 versenden
Serial Data Output to P10 RGB Display
Arduino Stepper motor Weird response
Serial communication help between 2 Boards SOLVED
Hoe kan ik deze code het beste splitsen in bijvoorbeeld classes
Board to board communication with interrupted connection
Relay circuit kills Arduino? Need help for how to protect the Arduino
LoRa received packet print in serial monitor but not on LED Matrix
Reading an electronic balance using RS232 and a MAX3232 and displaying the mass on an LCD, along with reading temperature and humidity
Strings vs c strings and strange behavior
SPO2 Monitor programing (Guidance Required) using SPO2 Module (Medical Graded)
Arduino + ccnet
Reading text from serial and compare the input always fails
Serial Ports for SAMD21 Xplained Pro?
Writing strings from the serial monitor to lcd
Problem with changing input variable and serial monitor
Is there no solution for this code?
Searching for debugging steps using serial communication
Why did I receive this inactive account deletion email?
USB Keyboard as input for Arduino Uno
Seriellen String zerlegen
RS232 from Arduino Uno not controling amplifier
Serial Communication Between ESP32 and Arduino Uno
Arduino Mega and fast serial communication
Update to Arduino Serial Input Basics Example #5
Need help making this bluetooth ball gun
Sending around 1000 bytes to Arduino
Acceleration Measurement with MPU 6050
Best/Easiest Method for Data Transfer?
Arduino powerline communication conflict
Conflict between SD library and IridiumSBD
How to call function on foreign UNO
String manipulation
Recieving hexadecimal serial communication
Speed O Meter serial display to LCD
Recieving hexadecimal serial communication
HC-12 receiver freezing when powered up
Wetterstation mit RS485
Sending Bitmap to TFT display using coolterm
RX / TX Kommunikation zwischen 2 Arduinos
Trying to replace SerialSoftware in a library
Accepting x,y,z coordinates in real time
Regular expressions
Probleme mit der Eingabefunktion
Communication from Mega to Uno
Need help: school project
Parsing Byte via Serial
How do I stop the previous code and restart it by a Bluetooth command?
Рroblem with transmitting a variable between two Arduino Pro Mini boards via UART
Serial Port Test Tool
Writing from Serial
Read a specific hex byte from a data packet
Behaviour of Serial.available() == N
Logic Daten an serielle Schnittstelle senden
How to read and write 24Cxx EEPROM data via SDA SCL pins
Trying to learn I2C (was RS485) to control things on my hobby railroad
Help with RS232 input that uses stx/etx error in terminal
How to enter a filename from Serial Monitor and use it to create a new data file?
Need to query RYLR998 LoRa device for its UID in my Arduino code
CNC Shield Alternative for an ESP32?
Verifying it .toInt is really catching an integer
Arduino serial.read von binary Daten nach integer
Lora rylr998 to rotate one servo 90 deg
Using an external platform to develop apps
Meneer van Dalen wacht op antwoord rekenmachine
Hardware serial port
Updating target values
Title: How to Increase Serial2 RX Buffer Size on Arduino/ESP32 to Receive Large Data
Arduino Nano, serial communication, servo speed control problem
Tinkerkit Controlling the Robot Arm Directly
Serial doesn't work
Trouble sending large amounts of data over serial
RS485 Communication network problem
Sedning data through serial and interpreting them
Serial sending floats values using char instead of String
PT100 collector to Arduino
Input data to serial monitor
Serial Communication, datatype issue
Problems when comparing a String
How to react to specific byte sequence over serial?
Understanding Events
ESP32 & Arduino Uno data processing from serial communication
PCA9685PW an Arduino Nano
Real communication between arduino and NodeMCU
Properly send multiple values over Bluetooth
Relay gets stuck and RF issue
Serial read_problem
String Data Parsing - Touchdesigner to Arduino to MG995 Servos
Bluetooth (HC-05) car controlled via joystick
Printh display nextion arduino
Compare hex values received via serial
Testing links in the new forum [Reported issue]
nRF24 data synchronization?
Generate NMEA sentensers form sesor data
How to solve extra output not needed[SOLVED]
Arduino and ESP8266 data communication using i2c
Sending strings from PC with Python
A thread for serious bugs in the new forum
Testing links in the new forum [Reported issue]
Testing links in the new forum [Reported issue]
The MEGA2560_MCP4261_Bluetooth sketch need help please
Needing to clear buffer for some reason
Hc-05 servo control
Using Laptop Keyboard to Trigger Interrupt
Multiple node mcu using spi
How to grow up advanced in Arduino coding and project making!?
Daten aus einer serieller Schnittstelle auslesen/auswerten
SEN0311 über serielle Softwareschnittstelle einlesen
SD card: retrieve numerical data split into different variables
ATTINY 2313 serial 7 segment Display
Engine Dyno Projekt
HC-05 Module Receiving random data when button is pressed
Serial Read Prog Not Working
Strtok() - Problem
Reading int array from serial
serialEvent as an interrupt
NRF24L01 bi-directional communication[opinion needed]
Problem mit Servokommunikation RS232 auf Mega 2560 R3
Analog data Serial communication
Analog data Serial communication
Need a way to communicate between two Arduino (nano and mega) over around 10 m
How to serialize data in string on 2 Arduinos
How to make real time changes from a computer?
Problem with rgb led

Continued from previous Post

Example 3 - A more complete system

The simple system in Example 2 will work well with a sympathetic human who does not try to mess it up. But if the computer or person sending the data cannot know when the Arduino is ready to receive there is a real risk that the Arduino will not know where the data starts.

If you would like to explore this, change the end marker in the previous program from \n to > so that you can include the end marker in your text for illustration purposes. (You can't manually enter a Newline character in the text you are sending from the Serial Monitor). And put the line ending back to "No line ending"

Now, with the revised code send qwert> and you will see that it behaves exactly the same as when you were using Newline as the end marker.

But if you try this asdfg>zxcvb you will only see the first part "asdfg". And then if you send qwert> you will see "zxcvbqwert" because the Arduino has become confused and cannot know that it should have ignored "zxcvb".

The answer to this problem is to include a start-marker as well as an end-marker.

// Example 3 - Receive with start- and end-markers

const byte numChars = 32;
char receivedChars[numChars];

boolean newData = false;

void setup() {
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvWithStartEndMarkers();
    showNewData();
}

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;
 
    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}

To see how it works try sending qwerty<asdfg>zxcvb and you will see that it ignores everything except "asdfg".

In this program you will notice that there is a new variable called recvInProgress. This is necessary because a distinction needs to be made between unwanted characters that arrive before the start marker and the valid characters that arrive after the start marker.

This version of the program is very similar to the Arduino code in this Python - Arduino demo.

How it works

It is important to notice that each time the function recvWithEndMarker() or recvWithStartEndMarker() is called it reads whatever characters may have arrived in the serial input buffer and places them in the array receivedChars.

If there is nothing in the buffer recvWithEndMarker() does not waste time waiting.

In the case of recvWithStartEndMarker() all characters are discarded until the start-marker is detected.

If the end-marker has not yet arrived it will try again when loop() next repeats.

For best results it is important to ensure that loop() can repeat as quickly as possible - hundreds or even thousands of times per second.

How many characters can be received?

In the examples I have assumed that you will not need to receive more than 32 bytes. That can easily be altered by changing the value in the constant numChars.

Note that the 64 byte size of the Arduino serial input buffer does not limit the number of characters that you can receive because the code in the examples can empty the buffer faster than new data arrives.

Things that are not used in the examples

You will notice that the examples here do not use any of these Arduino functions
Serial.parseInt()
Serial.parseFloat()
Serial.readBytes()
Serial.readBytesUntil()

All of these are blocking functions that prevent the Arduino from doing something else until they are satisfied, or until the timeout expires. The examples here do exactly the same job without blocking. That allows the Arduino to do other things while it is waiting for data to arrive.

serialEvent()

I don't recommend using this function - I prefer to deal with the Serial data when it suits me. It behaves just as if you had this code as the last thing in loop().

if (Serial.available() > 0) {
    mySerialEvent();
}

Clearing the input buffer

It is probably worth mentioning that the poorly named Serial.flush() function does not empty the input buffer. It is only relevant when the Arduino is sending data and its purpose is to block the Arduino until all outgoing the data has been sent.

If you need to ensure the Serial input buffer is empty you can do so like this

while (Serial.available() > 0) {
    Serial.read();
}

Continued in next Post

...R

25 Likes

Continued from previous Post

Receiving numbers rather than text

So far the examples have assumed you want to receive text. But perhaps you want to send a number or maybe a mix of text and numbers.

Example 4 - Receiving a single number from the Serial Monitor

The simplest case is where you want to type a number into the Serial Monitor (I am assuming you have line-ending set to newline). Let's assume you want to send the number 234. This is a variation on Example 2 and it will work with any integer value. Note that if you don't enter a valid number it will show as 0 (zero).

// Example 4 - Receive a number as text and convert it to an int

const byte numChars = 32;
char receivedChars[numChars];   // an array to store the received data

boolean newData = false;

int dataNumber = 0;             // new for this version

void setup() {
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvWithEndMarker();
    showNewNumber();
}

void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    
    if (Serial.available() > 0) {
        rc = Serial.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

void showNewNumber() {
    if (newData == true) {
        dataNumber = 0;             // new for this version
        dataNumber = atoi(receivedChars);   // new for this version
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        Serial.print("Data as Number ... ");    // new for this version
        Serial.println(dataNumber);     // new for this version
        newData = false;
    }
}

Example 5 - Receiving and parsing several pieces of data

It is also straightforward to receive several pieces of data in a single message and parse the data to assign them to individual variables. This example assumes you send something like <HelloWorld, 12, 24.7>. This is an extension of Example 3.

A function called parseData() has been added and the function showParsedData() takes the place of showNewData() in the earlier example.

// Example 5 - Receive with start- and end-markers combined with parsing

const byte numChars = 32;
char receivedChars[numChars];
char tempChars[numChars];        // temporary array for use when parsing

      // variables to hold the parsed data
char messageFromPC[numChars] = {0};
int integerFromPC = 0;
float floatFromPC = 0.0;

boolean newData = false;

//============

void setup() {
    Serial.begin(9600);
    Serial.println("This demo expects 3 pieces of data - text, an integer and a floating point value");
    Serial.println("Enter data in this style <HelloWorld, 12, 24.7>  ");
    Serial.println();
}

//============

void loop() {
    recvWithStartEndMarkers();
    if (newData == true) {
        strcpy(tempChars, receivedChars);
            // this temporary copy is necessary to protect the original data
            //   because strtok() used in parseData() replaces the commas with \0
        parseData();
        showParsedData();
        newData = false;
    }
}

//============

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;

    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

//============

void parseData() {      // split the data into its parts

    char * strtokIndx; // this is used by strtok() as an index

    strtokIndx = strtok(tempChars,",");      // get the first part - the string
    strcpy(messageFromPC, strtokIndx); // copy it to messageFromPC
 
    strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
    integerFromPC = atoi(strtokIndx);     // convert this part to an integer

    strtokIndx = strtok(NULL, ",");
    floatFromPC = atof(strtokIndx);     // convert this part to a float

}

//============

void showParsedData() {
    Serial.print("Message ");
    Serial.println(messageFromPC);
    Serial.print("Integer ");
    Serial.println(integerFromPC);
    Serial.print("Float ");
    Serial.println(floatFromPC);
}

Binary data

So far we have been receiving character data - for example the number 121 is represented by the characters '1', '2' and '1'. It is also possible to send that value as binary data in a single byte - it happens to be the Ascii value for the character 'y'. Note that 121 in decimal is the same as 0x79 in HEX.

Note that if you are sending binary data it is quite likely that you will need to send as data the same values that are used for the start- and end-markers. That goes beyond the scope of this Tutorial and one way of doing it is illustrated in the demo here.

The examples that follow assume that the binary data will NEVER include the byte values used for the start- and end-markers. For simplicity I will continue to use < and > as the markers. The byte values for those characters are 0x3C and 0x3E. This will allow you to test the program from the Serial Monitor by sending, for example, <24y> which will be interpreted by the receiving program as the binary values 0x32, 0x34 and 0x79. These are the Ascii codes for 2, 4 and y.

Of course it would be more usual for binary data to be sent by another computer program - on another Arduino or on a PC.

Example 6 - Program to receive binary data

This is adapted from Example 3

// Example 6 - Receiving binary data

const byte numBytes = 32;
byte receivedBytes[numBytes];
byte numReceived = 0;

boolean newData = false;

void setup() {
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvBytesWithStartEndMarkers();
    showNewData();
}

void recvBytesWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    byte startMarker = 0x3C;
    byte endMarker = 0x3E;
    byte rb;
   

    while (Serial.available() > 0 && newData == false) {
        rb = Serial.read();

        if (recvInProgress == true) {
            if (rb != endMarker) {
                receivedBytes[ndx] = rb;
                ndx++;
                if (ndx >= numBytes) {
                    ndx = numBytes - 1;
                }
            }
            else {
                receivedBytes[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                numReceived = ndx;  // save the number for use when printing
                ndx = 0;
                newData = true;
            }
        }

        else if (rb == startMarker) {
            recvInProgress = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in (HEX values)... ");
        for (byte n = 0; n < numReceived; n++) {
            Serial.print(receivedBytes[n], HEX);
            Serial.print(' ');
        }
        Serial.println();
        newData = false;
    }
}

END

As usual, comments and suggested improvements are welcome but please do not ask questions about your own project in this Thread.

...R

23 Likes
How do i print this string and float value
Serial read_int
AccelStepper library - motor ticks when turning
Clean thread. Multiple AC current and voltage detection
Serielle Daten auswerten und an ThingSpeak
Serial Communication between two Arduino boards for sending 2 sets of integers
Insert value in Serial Monitor and save it into a variable
Serial Input Basics (example #5) - using parsed text
Sending multiples variables via Serial
Reading RS232 Serial Data from a Pulse Ox
Using atoi() for bytes and booleans?
[SOLVED] SoftwareSerial simple message
LED Dimmen mit Serial Port! Bitte :/
New text / CSV / TSV / etc. parser library
Send the asci command to get the sensor value
Serial communication seems to be slower now
SD card: retrieve numerical data split into different variables
Communication between Arduino and Python for messages
Hello i need some help with ultrasonic sensors by communition serial
Serial data Transfer
I can't convert string to int
Converting float to send
How to send and recieve longitude and latitude between 2 arduinos
Serial Input Basic's usage of Strtok() unsafe?
Arduino RS232 Serial Communication to Laser Control Board
Serielle Daten auswerten und an ThingSpeak
Arduino Uno cannot communicate with Arduino Mega
Stepper Motor Control with Serial communication between python and teensy 4.1
Arduino receiving data through HC12 but the code gets stuck on one value only
Serial Communication between ArduinoIDE and Simulink for controlling motor
Arduino Kits with lots of parts
Recibir datos de un arduino a otro
KeyPad Counter Project Season 2
Serial Input Basic's usage of Strtok() unsafe?
Serial communication timing issue
Interpreting serial from an old instrument
I can't convert string to int
MATLAB - Arduino Uno Serial Communication Issue
Why doesn't a few simple changes work?
Making motion controller (something like avata motion sensor) for UAV with MPU6050 (need help)
What is wrong with sending data to arduino from serial port?
Help regarding Two Arduino Rx Tx Serial communication!
~~Dissect~~ Parsing Commands
Serial Communication Help
Serial.h library question
Hilfe bei Erstellung eines "einfachen" Codes
Getting data from two or more sensors - Arduino/P5.JS
Reading data from sd card file to set multiple alarms using ds3231 module
Serial communication issue between Arduino Nano every and UNO wifi

Reserved for future use - please ignore

...R

1 Like

Great tutorial, especially the use of a char* and parsing...

While it's not really suitable for beginners, I feel that you dismiss Serialevent() far too easily...
Depending on using Serial.Available() is akin to using delay() instead of millis().

Serialevent() allows your program to acquire incoming characters 'asynchronously' which is a big deal in embedded or real-time systems.

Definitely not needed for flashing LED strips, but as users need more predictable functionality it's worth learning about.

lastchancename:
Serialevent() allows your program to acquire incoming characters 'asynchronously'

There is nothing related to events in serialEvent, it is just a hidden synchronous 'if Serial.available()' call to a function.

1 Like

Great; finally a cleanup of the original that was far too big to dig through.

Suggestion
Maybe ask a mod to lock this. People can ask questions in another thread.

Maybe ask a mod to lock this. People can ask questions in another thread.

That will happen in a day or two when I am satisfied that I have not made a stupid mistake somewhere.

Thanks for the various kind comments.

...R

6 Likes

2 posts were split to a new topic: Compilation error from "Serial Input Basics" tutorial code

I really appreciate your sharing this information. I have not been involved with c++ for very long and there is so much more to learn than with Visual Basic. So much of Visual Basic is hard-coded into the language while c++ is more of a roll-your-own language with much more potential and much more complexity. I can see now how strings in VB are treated the same only the process is wrapped into a more friendly package. Combining individual characters into a string is done by VB while in c++ it is handled by the programmer. Thank you again for sharing.

4 Likes