MiniSerial.ino 690 B

1234567891011121314151617181920212223242526272829
  1. // This example illustrates use of SdFat's
  2. // minimal unbuffered AVR Serial support.
  3. //
  4. // This is useful for debug and saves RAM
  5. // Will not work on Due, Leonardo, or Teensy
  6. #include <SPI.h>
  7. #include "SdFat.h"
  8. #include "FreeStack.h"
  9. #ifdef UDR0 // Must be AVR with serial port zero.
  10. #include "MinimumSerial.h"
  11. MinimumSerial MiniSerial;
  12. void setup() {
  13. MiniSerial.begin(9600);
  14. MiniSerial.println(FreeStack());
  15. }
  16. void loop() {
  17. int c;
  18. MiniSerial.println(F("Type any Character"));
  19. while ((c = MiniSerial.read()) < 0) {}
  20. MiniSerial.print(F("Read: "));
  21. MiniSerial.println((char)c);
  22. while (MiniSerial.read() >= 0) {}
  23. }
  24. #else // UDR0
  25. #error no AVR serial port 0
  26. #endif // UDR0