#include <LiquidCrystal.h>
const int btn_sg = 2;
const int btn_si = 3;
const int btn_se = 4;
const int btn_at = 5;
int papel = 10;
const int rs = 12, en = 11, d4 = 9, d5 = 8, d6 = 7, d7 = 6;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// put your setup code here, to run once:
pinMode(btn_sg, INPUT);
pinMode(btn_si, INPUT);
pinMode(btn_se, INPUT);
pinMode(btn_at, INPUT);
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.blink();
for (int c=0; c<=16; c++) {
lcd.clear();
lcd.setCursor(c, 0);
lcd.print("Bem Vindo!");
delay(200);
}
}
void loop() {
// put your main code here, to run repeatedly:
acionabtn();
}
boolean impcheck() {
if (papel > 0) {
return true;
} else {
return false;
}
}
void imprimir(String mensagem) {
if (impcheck() == true) {
Serial.println(mensagem);
} else {
Serial.println("A impressora está sem papel...");
}
}
void acionabtn() {
if (digitalRead(btn_sg) == HIGH) {
imprimir("Senha Geral");
for (int c=0; c<=16; c++) {
lcd.clear();
lcd.setCursor(c, 0);
lcd.print("Imprimindo...");
delay(300);
}
for (int c=0; c<=16; c++) {
lcd.clear();
lcd.setCursor(c, 0);
lcd.print("Senha Geral");
delay(300);
}
papel--;
delay(1000);
}
if (digitalRead(btn_si) == HIGH) {
imprimir("Senha Idoso");
for (int c=0; c<=16; c++) {
lcd.clear();
lcd.setCursor(c, 0);
lcd.print("Imprimindo Senha Idoso");
delay(300);
}
papel--;
delay(1000);
}
if (digitalRead(btn_se) == HIGH) {
imprimir("Senha Exames");
for (int c=0; c<=16; c++) {
lcd.clear();
lcd.setCursor(c, 0);
lcd.print("Imprimindo Senha Exames");
delay(300);
}
papel--;
delay(1000);
}
if (digitalRead(btn_at) == HIGH) {
imprimir("Senha Atendimento");
for (int c=0; c<=16; c++) {
lcd.clear();
lcd.setCursor(c, 0);
lcd.print("Imprimindo Senha Atendimento");
delay(300);
}
papel--;
delay(1000);
}
}