User manual

wiring work is required for this. On the PC-side, a virtual
Comport is produced when installing the Arduino™-PCB. This is
already used for programming. Now, we can also simply use it to
transfer data to the PC. For this, we only need to initialise
the UART interface in the program. This is configured
with
Serial.begin()
. The parameter
19200
between the brackets
represents the transfer speed. Initialisation only needs to be
executed once at program start in the
Setup()
-function.
001 Serial.begin(19200)
Baud is the unit for the symbol rate in message and telecom-
munications technology. 19200 Baud means , that 19,200 symbols
per second will be transferred. The symbol rate can contain
different numbers of bits depending on coding and must be set
equally on the transmitter and receiver sides to permit
transmission.
The following lines are now used to send the measured result of
the ADC (0 to 1013) to the PC directly without prior conversion.
Conversion to Volt takes place in the PC-program, since we only
need to send two individual bytes to the PC this way, which are
much easier to evaluate than a string (ASCII-character string).
Now the buffer of the UART-interface will be emptied with
flush
.
001 Serial.flush()
Now we will take apart the analogue measured value, which ranges
from 0 to 1023, into a high and a low byte. We will get the high
byte by dividing the measured value by 256.
001 highbyte = adc_raw / 256
We will get the low byte with the modulo operation 256.
001 lowbyte = adc_raw % 256
Then we will send first the high byte and then the low byte to
the PC.
001 Serial.write(highbyte)
002 Serial.write(lowbyte)