

The following graph shows the number of values generated as a function of serial port speeds. This is slightly less than double the values you get when using 9600 baud rate. When you use 19200 baud, that is, twice the 9600, you get 1158 values. Now, how about we vary the speed of the port? Running the algorithm using a 4800 baud rate yields 297 values, that is, slightly less than half of the values obtained when 9600 baud is used. If this algorithm is repeated several times, 585 values are always generated. These 585 values plotted in Excel describe a graph of a sine wave, as shown in the following image. This algorithm will generate a total of 585 values. The following results are seen on the serial monitor:
#Web serial port communication arduino code
This code generates values between 5 and 10 seconds after execution starts. A sine wave has certain characteristics such as amplitude, period, frequency, and angular frequency. To carry out the tests, I will ask the Arduino to generate the values of a sine wave for me and print them to the Serial Monitor. For the purposes of this post, an Arduino Nano (Atmega328P) will be considered. But what is the effect of using one speed or the other? To observe this type of phenomenon, I have designed a small code as an experiment that will allow us to understand in a simpler way the effect of the speed of serial serial communication on the execution of our programs on Arduino.


These are the default values for communication between Arduino and a computer, which can be seen in the Serial Monitor of the Arduino IDE. This line of code tells the Arduino to initiate communication with the computer (or any device connected to the RX and TX pins) with a serial communication rate of 9600 bits per second (baud).
