Arduino GBPrinter Datalogger


SUBMITTED BY: Guest

DATE: Jan. 18, 2014, 11:03 a.m.

FORMAT: C++

SIZE: 1.5 kB

HITS: 1054

  1. // ARDUINO GB PRINTER (BY O.N.)
  2. #include <avr/pgmspace.h>
  3. #include <GBPrinter.h>
  4. GBPrinter printer;
  5. String readString;
  6. boolean line = false;
  7. void setup(){
  8. printer.attach(8,9,10);
  9. Serial.begin(9600);
  10. }
  11. void loop() {
  12. //expect a string like wer,qwe rty,123 456,hyre kjhg,
  13. //or like hello world,who are you?,bye!,
  14. while (Serial.available()) {
  15. delay(6);
  16. char c = Serial.read(); //gets one byte from serial buffer
  17. readString += c;
  18. } //makes the string readString
  19. if (readString.length()>9) {
  20. Serial.print("Printing: ");
  21. readString.toUpperCase();
  22. Serial.println(readString); //prints string to serial port out
  23. char yte[readString.length() + 1];
  24. readString.toCharArray(yte, readString.length() + 1);
  25. gbprintln(yte);
  26. readString=""; //clears variable for new input
  27. }
  28. }
  29. void gbprint(char* textt){
  30. if(printer.init()){
  31. printer.text(textt,GBPrinterFontsRegular, false);
  32. printer.band(NULL, false);
  33. printer.print(GBPrinter::defaultPrintProperties());
  34. printer.wait();
  35. }
  36. }
  37. void gbprintln(char* textt){
  38. if(printer.init()){
  39. printer.text(textt,GBPrinterFontsRegular, false);
  40. printer.text(" ",GBPrinterFontsRegular, false);
  41. printer.band(NULL, false);
  42. printer.print(GBPrinter::defaultPrintProperties());
  43. printer.wait();
  44. }
  45. }

comments powered by Disqus