write Value
Write a name:value pair as a line of text to the serial port.
serial.writeValue("x", 0);
A name:value pair is a string that has both a name for a value and the value itself. If you want to send a temperature value of 32 degrees as a name:value pair, it would go to the serial port as this: “temperature:32”. This is a good way to connect a number value to it’s meaning.
So, ||serial:write value||
does this but you give the name and the value as two parts and it
sends it as a pair.
Parameters
- name: a string that is the name part of the name:value pair
- value: a number that is the value part of the name:value pair
Example
Send name:value pairs for odd and even numbers to the serial port.
for (let i = 0; i < 10; i++) {
if (i % 2 > 0) {
serial.writeValue("odd", i)
} else {
serial.writeValue("even", i)
}
}
See also
serial