This circuit is designed to interface an Arduino UNO with an RFID-RC522 module, an I2C LCD 16x2 screen, and multiple pushbuttons. The purpose of the circuit is to create a smart trolley billing system that can add or remove items from a bill using RFID tags and display the total bill on the LCD screen. The pushbuttons are used to control the addition and removal of items and to reset the billing amount.
/****************************************************
* Code Designed By : Rahul Jadhav Youtube Channel
****************************************************/
/******************RFID Connection:*********************
RFID PIN ARDUINO PIN
SDA 10
SCK 13
MOSI 11
MISO 12
GND GND
RST 9
3.3v 3.3v
******************************************************/
/***** LCD Connection ***********************************
LCD PIN ARDUINO PIN
SCL SCL (Arduino Last pin)
SDA SDA (Arduino Second last pin)
VCC 5v
GND GND
******************************************************/
/***** Button Connection ***********************************
Button PIN ARDUINO PIN
Remove_Button 2
Add_button 3
Reset_button 4
VCC 5v
GND GND
*****************************************************/
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int remove_button = 2;
const int add_button = 3;
const int reset_button = 4;
// const int buzzer_Pin = 5;
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
struct item
{
String item_name;
String item_number;
int item_price;
};
const int number_of_item = 4;
const item item_list[number_of_item]=
{
//Item Name Item RFID Number Item Price
{"Tata salt", "B3 23 E4 11", 100},
{"Milk Powder", "A3 51 A0 0D", 50},
{"Bournvita", "13 1F A3 0D", 20},
{"Ball_Pen", "E3 68 DC 12", 10},
};
int bill_amount = 0;
int remove_buttonState = 0;
int add_buttonState = 0;
int reset_buttonState = 0;
int add_item_flag = 1;
int remove_item_flag = 0;
void setup()
{
pinMode(remove_button, INPUT);
pinMode(reset_button, INPUT);
pinMode(add_button, INPUT);
// pinMode(buzzer_Pin, OUTPUT);
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println("Approximate your card to the reader...");
Serial.println();
// digitalWrite(buzzer_Pin, LOW);
lcd.init();
// Turn on the Backlight
lcd.backlight();
lcd.clear();
// Set cursor (Column, Row)
lcd.setCursor(0, 0);
lcd.print("Smart Trolley");
lcd.setCursor(0,1);
lcd.print("Billing System");
delay(2000);
lcd.clear();
// Set cursor (Column, Row)
lcd.setCursor(0, 0);
lcd.print("Start purchasing");
lcd.setCursor(0,1);
lcd.print("your item");
delay(100);
}
void loop()
{
remove_buttonState = digitalRead(remove_button);
add_buttonState = digitalRead(add_button);
reset_buttonState = digitalRead(reset_button);
if(remove_buttonState)
{
add_item_flag = 0;
remove_item_flag = 1;
lcd.clear();
// Set cursor (Column, Row)
lcd.setCursor(0, 0);
lcd.print("You Can now");
lcd.setCursor(0,1);
lcd.print("Remove your item");
delay(2000);
}
else if(add_buttonState)
{
add_item_flag = 1;
remove_item_flag = 0;
lcd.clear();
// Set cursor (Column, Row)
lcd.setCursor(0, 0);
lcd.print("You Can now");
lcd.setCursor(0,1);
lcd.print("add your item");
delay(2000);
}
else if(reset_buttonState)
{
lcd.clear();
// Set cursor (Column, Row)
lcd.setCursor(0, 0);
lcd.print("Resetting");
lcd.setCursor(0,1);
lcd.print("Trolley data");
delay(2000);
lcd.clear();
// Set cursor (Column, Row)
lcd.setCursor(0, 0);
lcd.print("Start Purchasing");
lcd.setCursor(0,1);
lcd.print("Your item");
delay(2000);
bill_amount = 0;
}
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor