mirror of
https://github.com/una1veritas/mac-floppy-emu.git
synced 2024-06-12 19:18:07 +00:00
34 lines
794 B
Plaintext
Executable File
34 lines
794 B
Plaintext
Executable File
/*
|
|
* Demo of ArduinoInStream and ArduinoOutStream
|
|
*/
|
|
#include <SdFat.h>
|
|
|
|
// create serial output stream
|
|
ArduinoOutStream cout(Serial);
|
|
|
|
// input buffer for line
|
|
char cinBuf[40];
|
|
|
|
// create serial input stream
|
|
ArduinoInStream cin(Serial, cinBuf, sizeof(cinBuf));
|
|
//------------------------------------------------------------------------------
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
void loop() {
|
|
int32_t n;
|
|
|
|
cout << "enter an integer\n";
|
|
|
|
cin.readline();
|
|
|
|
if (cin >> n) {
|
|
cout << "The number is: " << n << endl;
|
|
} else {
|
|
// will fail if no digits or not in range [-2147483648, 2147483647]
|
|
cout << "Invalid input: " << cinBuf << endl;
|
|
}
|
|
cout << endl;
|
|
}
|