This code with cout that works for Teensy 2, 3.x.
I just encountered this library though it may have been around a while.
Demo example of use of library:
The library for Teensy/Arduino is explained at
http://arduiniana.org/libraries/streaming/
The latest version of Streaming is available http://arduiniana.org/Streaming/Streaming5.zip
Download, drop the folder in the main IDE's library folder and try the example.
Note that you can use, instead of "Serial", "Serial1" etc within the classes derived from Print.
I just encountered this library though it may have been around a while.
Demo example of use of library:
Code:
#include <Streaming.h>
void setup()
{
Serial.begin(9600);
delay(5000); // <<<<<<<<<<<<<<<<<<<<<<<< I added this to give time to open serial terminal/monitor
int lettera = 'A';
int month = 4, day = 17, year = 2009;
Serial << "This is an example of the new streaming" << endl;
Serial << "library. This allows you to print variables" << endl;
Serial << "and strings without having to type line after" << endl;
Serial << "line of Serial.print() calls. Examples: " << endl;
Serial << "A is " << lettera << "." << endl;
Serial << "The current date is " << day << "-" << month << "-" << year << "." << endl;
Serial << "You can use modifiers too, for example:" << endl;
Serial << _BYTE(lettera) << " is " << _HEX(lettera) << " in hex. " << endl;
}
void loop()
{}
The library for Teensy/Arduino is explained at
http://arduiniana.org/libraries/streaming/
The latest version of Streaming is available http://arduiniana.org/Streaming/Streaming5.zip
Download, drop the folder in the main IDE's library folder and try the example.
Note that you can use, instead of "Serial", "Serial1" etc within the classes derived from Print.