PrinterThermal 2.16 KB
#include <PString.h>
#include "Adafruit_Thermal.h"
#include "adalogo.h"
#include "adaqrcode.h"
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;

#include "SoftwareSerial.h"
#define TX_PIN 2 // Arduino transmit  YELLOW WIRE  labeled RX on printer
#define RX_PIN 3 // Arduino receive   GREEN WIRE   labeled TX on printer

SoftwareSerial mySerial(RX_PIN, TX_PIN); 
Adafruit_Thermal printer(&mySerial);   

int hitung=0;

const int buttonPin = 12;
int buttonState=0;             
int lastButtonState = LOW;  
long lastDebounceTime = 0;  
long debounceDelay = 50;

void setup() {
   Wire.begin();
    RTC.begin();
     if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
 pinMode(buttonPin, INPUT);
  
  pinMode(7, OUTPUT); digitalWrite(7, LOW);

 
  mySerial.begin(9600);  // Initialize SoftwareSerial
  
  printer.begin();        // Init printer (same regardless of serial type)

  
  
}

void loop() {
  
  buttonState = digitalRead(buttonPin);
   if (buttonState == HIGH) {     
    hitung+=1;
    char buffer[40];
  PString str(buffer, sizeof(buffer));
  if(hitung<100)
  {
    str.print(0);
    if(hitung<10)
    {
      str.print(0);
    }
  }
  else if(hitung<10)
    {
      str.print(0);
    }
  str.print(hitung);
    printer.printBitmap(adalogo_width, adalogo_height, adalogo_data);
printer.boldOn();
  printer.justify('C');

   printer.setSize('S');
  printer.println(F("Nomor antrian :"));
 
  printer.setSize('L');
  printer.println(str);
   printer.setSize('S');
   printer.boldOn();
  printer.println(F("wisnu tes..!!"));
  DateTime now = RTC.now();
  str.begin();
  str.print(now.day(), DEC);
  str.print('-');
  str.print(now.month(), DEC);
  str.print('-');
  str.print(now.year(), DEC);
  str.print(' ');
  str.print(now.hour(), DEC);
  str.print(':');
  if((now.minute(), DEC)<10)
  {
    str.print('0');
  }
  str.print(now.minute(), DEC);
  str.print(':');
  if((now.second(), DEC)<10)
  {
    str.print('0');
  }
  str.print(now.second(), DEC);
  printer.println(str);
    printer.feed(4);
  printer.sleep();      
  delay(3000);         
  printer.wake();       
  printer.setDefault(); 
  
  } 
  else {
   
  }
}