StreamIn
An input unit that can receive values transmitted through a stream – for example, the Arduino serial line. Values are sent in clear text and separated by newlines and/or carriage returns.
Example
Controls the value of a LED using serial. Try opening the serial monitor and sending values between 0 and 1.
#include <Plaquette.h>
StreamIn serialIn(Serial);
AnalogOut led(9);
void begin() {}
void step() {
serialIn >> led;
}
To run this example:
Upload the code.
In the Arduino software open the serial monitor: Tools > Serial Monitor.
Make sure the default baudrate of 9600 bps is selected.
Make sure one of the options “Newline”, “Carriage return”, or “Both NL + CR” is selected.
Write a number between 0.0 and 1.0 and press “Enter”. This should allow you to set the LED intensity.
Try different values.
Reference
-
class StreamIn : public AnalogSource
Stream/serial input. Reads float values using Arduino built-in parseFloat().