0% found this document useful (0 votes)
49 views5 pages

Coding Print Antrian

The document defines an Arduino sketch that uses an Adafruit Thermal Printer and RTC module to print ticket numbers. It initializes libraries and pins for the printer, RTC, and buttons. The loop prints the next or previous ticket number when buttons 1 or 2 are pressed, and resets the counter when button 3 is pressed. It also prints the current date/time from the RTC each time.

Uploaded by

C SYAHBANA
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
49 views5 pages

Coding Print Antrian

The document defines an Arduino sketch that uses an Adafruit Thermal Printer and RTC module to print ticket numbers. It initializes libraries and pins for the printer, RTC, and buttons. The loop prints the next or previous ticket number when buttons 1 or 2 are pressed, and resets the counter when button 3 is pressed. It also prints the current date/time from the RTC each time.

Uploaded by

C SYAHBANA
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

#include <PString.

h>

#include "Adafruit_Thermal.h"

#include <Wire.h>

#include "RTClib.h"

RTC_DS1307 RTC;

#include "SoftwareSerial.h"

#define TX_PIN 7

#define RX_PIN 6

SoftwareSerial mySerial(RX_PIN, TX_PIN);

Adafruit_Thermal printer(&mySerial);

int hitung=0;

const int buttonPin = 12;

const int buttonPin2 = 11;

const int buttonPin3 = 10;

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_PULLUP);

pinMode(buttonPin2, INPUT_PULLUP);

pinMode(buttonPin3, INPUT_PULLUP);

mySerial.begin(9600);

printer.begin();
}

void loop() {

buttonState = digitalRead(buttonPin);

if (!buttonState) {

printer.wake();

printer.setDefault();

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.boldOn();

printer.justify('C');

printer.setSize('M');

printer.println(F("Nomor Antrian :"));

printer.setSize('L');

printer.println(str);

printer.setSize('S');

DateTime now = RTC.now();

str.begin();

str.print("tgl.");

str.print(now.day(), DEC);
str.print('-');

str.print(now.month(), DEC);

str.print('-');

str.print(now.year(), DEC);

str.print(' ');

int z=0;

z=now.hour(), DEC;

if(z<10)str.print('0');

str.print(z);

str.print(':');

z=now.minute(), DEC;

if(z<10)str.print('0');

str.print(now.minute(), DEC);

str.print(':');

z=now.second(), DEC;

if(z<10)str.print('0');

str.print(now.second(), DEC);

printer.println(str);

printer.println("dibuat oleh duwiarsana.com");

printer.feed(6);

printer.sleep();

printer.wake();

printer.setDefault();

if(!(digitalRead(buttonPin2))){

printer.wake();

printer.setDefault();

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);

if(hitung<0)hitung=0;

str.print(hitung);

printer.boldOn();

printer.justify('C');

printer.setSize('M');

printer.println(F("Nomor Antrian :"));

printer.setSize('L');

printer.println(str);

printer.setSize('S');

DateTime now = RTC.now();

str.begin();

str.print("tgl.");

str.print(now.day(), DEC);

str.print('-');

str.print(now.month(), DEC);

str.print('-');

str.print(now.year(), DEC);

str.print(' ');

int z=0;

z=now.hour(), DEC;

if(z<10)str.print('0');

str.print(z);

str.print(':');

z=now.minute(), DEC;

if(z<10)str.print('0');

str.print(now.minute(), DEC);

str.print(':');

z=now.second(), DEC;

if(z<10)str.print('0');

str.print(now.second(), DEC);

printer.println(str);

printer.println("dibuat oleh duwiarsana.com");

printer.feed(6);

printer.sleep();
//delay(3000);

printer.wake();

printer.setDefault();

if(!(digitalRead(buttonPin3))){

printer.wake();

printer.setDefault();

printer.justify('C');

printer.setSize('M');

printer.println(F("Printer Direset"));

hitung=0;

printer.feed(6);

printer.sleep();

//delay(3000);

printer.wake();

printer.setDefault();

You might also like