Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- #include <SPI.h>
- #include <MFRC522.h>
- #include <LiquidCrystal_I2C.h>
- #include <Wire.h>
- #define SS_PIN 10
- #define RST_PIN 9
- #define buzzer 6
- MFRC522 mfrc522(SS_PIN, RST_PIN);
- LiquidCrystal_I2C lcd(0x27, 16, 2);
- //char input[12];
- String input;
- int count = 0;
- int a;
- int p1 = 0, p2 = 0, p3 = 0, p4 = 0;
- int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
- double total = 0;
- int count_prod = 0;
- void setup () {
- Serial.begin(9600);
- SPI.begin();
- mfrc522.PCD_Init();
- pinMode(A3, INPUT_PULLUP);
- pinMode(4, OUTPUT);
- pinMode(5, OUTPUT);
- pinMode(buzzer, OUTPUT);
- lcd.init();
- lcd.init();
- lcd.backlight();
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print(" AUTOMATIC BILL");
- delay (2000);
- lcd.setCursor(0, 1);
- lcd.print(" SHOPPING CART ");
- delay (2000);
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("WELCOME TO");
- delay (2000);
- lcd.setCursor(3, 1);
- lcd.print("SUPER MARKET");
- delay (2000);
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Plz Add iTem");
- }
- void loop() {
- readRFID();
- int a = digitalRead(A3);
- if (input == "29 36 CF B8" && (a == 1))
- {
- lcd.setCursor(0, 0);
- lcd.print("Butter Added ");
- lcd.setCursor(0, 1);
- lcd.print("Price :- 10.00 ");
- p1++;
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- total = total + 10.00;
- count_prod++;
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- showTotal();
- input = "";
- }
- else if (input == "29 36 CF B8" && (a == 0))
- {
- if (p1 > 0)
- {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Butter Removed!!! ");
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- p1--;
- total = total - 10.00;
- count_prod--;
- lcd.clear();
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- showTotal();
- input = "";
- }
- else
- {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Not in cart!!! ");
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- showTotal();
- input = "";
- }
- }
- if (input == "C6 91 09 2B" && (a == 1))
- {
- lcd.setCursor(0, 0);
- lcd.print("Milk Added ");
- lcd.setCursor(0, 1);
- lcd.print("Price :- 20.00 ");
- p2++;
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- total = total + 20.00;
- count_prod++;
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- showTotal();
- input = "";
- }
- else if (input == "C6 91 09 2B" && (a == 0))
- {
- if (p2 > 0)
- {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Milk Removed!!! ");
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- p2--;
- total = total - 20.00;
- count_prod--;
- lcd.clear();
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- showTotal();
- input = "";
- }
- else
- {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Not in cart!!! ");
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- showTotal();
- input = "";
- }
- }
- if (input == "03007C2DA0F2" && (a == 1))
- {
- lcd.setCursor(0, 0);
- lcd.print("Tea Added ");
- lcd.setCursor(0, 1);
- lcd.print("Price :- 25.00 ");
- p3++;
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- total = total + 25.00;
- count_prod++;
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- showTotal();
- input = "";
- }
- else if (input == "03007C2DA0F2" && (a == 0))
- {
- if (p3 > 0)
- {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Tea Removed!!! ");
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- p3--;
- total = total - 25.00;
- count_prod--;
- lcd.clear();
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- showTotal();
- input = "";
- }
- else
- {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Not in cart!!! ");
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(2000);
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- lcd.clear();
- input = "";
- }
- }
- }
- void readRFID() {
- // Look for new cards
- if ( ! mfrc522.PICC_IsNewCardPresent())
- {
- return;
- }
- // Select one of the cards
- if ( ! mfrc522.PICC_ReadCardSerial())
- {
- return;
- }
- //Show UID on serial monitor
- Serial.println ("");
- Serial.println("UID tag :");
- String content = "";
- byte letter;
- for (byte i = 0; i < mfrc522.uid.size; i++)
- {
- content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
- content.concat(String(mfrc522.uid.uidByte[i], HEX));
- content.toUpperCase();
- }
- input = content.substring(1);
- digitalWrite(buzzer,1);
- delay(500);
- digitalWrite(buzzer,0);
- Serial.println(input);
- lcd.setCursor(0, 1);
- lcd.print(input);
- }
- void showTotal() {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Total Price :-");
- lcd.setCursor(0, 1);
- lcd.print(total);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement