Advertisement
Guest User

Thermal Printer Example

a guest
Jun 1st, 2015
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. bool buttonpressed = false;
  2. int button = 30;  
  3.  
  4. void setup() {
  5.   //setup button on board
  6.   pinMode(button, INPUT);
  7.  
  8.   Serial1.begin(19200); // Use this instead if using hardware serial  
  9.  
  10.   //Print Settings-----------------
  11.   //Modify the print speed and heat
  12.   Serial1.write(27);
  13.   Serial1.write(55);
  14.   Serial1.write(7); //Default 64 dots = 8*('7'+1)
  15.   Serial1.write(255); //Default 80 or 800us
  16.   Serial1.write(255); //Default 2 or 20us
  17.  
  18.   //Modify the print density and timeout
  19.   Serial1.write(18);
  20.   Serial1.write(35);
  21.   int printSetting = (15<<4) | 15;
  22.   Serial1.write(printSetting); //Combination of printDensity and printBreakTime
  23.   //-------------------------------
  24. }
  25.  
  26. void Print()
  27. {
  28.   //printed lines
  29.   Serial1.println("Hello World!");
  30.   Serial1.println("(0.o)");
  31.  
  32.   delay(3000L);         // Sleep for 3 seconds
  33. }
  34.  
  35. void loop()
  36. {
  37.   if(digitalRead(button))
  38.   {
  39.     if(!buttonpressed){
  40.     Print();
  41.     buttonpressed = true;
  42.     }
  43.   } else {
  44.     buttonpressed = false;
  45.   }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement