#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <Servo.h>
Servo myservo;
int pos = 0;
int rate = 0;
float discount = 0;
int tax = 0;
int billTotal = 0;
int productCode = 0;
void setup() {
myservo.attach(6);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
Wire.begin();
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Smart Shopping ");
delay(200);
lcd.setCursor(0,1);
lcd.print("Trolley");
delay(2000);
lcd.clear();
delay(1000);
myservo.write(pos);
delay(300);
}
void loop() {
if(digitalRead(2) == HIGH)
{
productCode = 1; //Special value / product code of every different product
}
if(digitalRead(3) == HIGH)
{
productCode = 2;
}
if(digitalRead(4) == HIGH)
{
productCode = 3;
}
if(productCode == 0)
{
lcd.setCursor(0,0);
lcd.print("Scan New Product");
delay(1000);
}
if(productCode == 1)
{
lcd.setCursor(0,0);
lcd.print("Product = Biscuits");
delay(1000);
rate = 10; //example rate of biscuit
discount = 2; // example discount in percent
tax = 12; //Example tax
billTotal = billTotal + rate;
}
if(productCode == 2)
{
lcd.setCursor(0,0);
lcd.print("Product = Any Grocery 1");
delay(1000);
rate = 40; //example rate of biscuit
discount = 8; // example discount in percent
tax = 5; //Example tax
billTotal = billTotal + rate; //total new bill amount ater scanning of new product
}
if(productCode == 3)
{
lcd.setCursor(0,0);
lcd.print("Product = any product 2");
delay(1000);
rate = 50; //example rate of biscuit
discount = 20; // example discount in percent
tax = 18; //Example tax
billTotal = billTotal + rate; //total new bill amount ater scanning of new product
}
lcd.setCursor(0,1);
lcd.print("Total Bill = ");
lcd.print(billTotal);
lcd.print("Rs ");
delay(200);
lcd.setCursor(0,2);
lcd.print("Discount= ");
lcd.print(discount);
lcd.print("% ");
lcd.setCursor(10,2);
lcd.print("Tax= ");
lcd.print(tax);
lcd.print(" %");
lcd.setCursor(0,3);
lcd.print("Expiry = 03/04/2026 ");
rate = 0;
discount = 0;
tax = 0;
if(digitalRead(5) == HIGH)
{
for (pos = 0; pos <= 90; pos += 1)
{
myservo.write(pos);
delay(3);
}
delay(10000);
myservo.write(pos);
delay(200);
}
}