I need help to write program for items billing, i want to add items and shows total bill after individual prices

It can be done, with a small set of products in the inventory.
About 5 years ago,

i used a MEGA2560 with LCd, selection buttons / menu scrollling, LORA radios, 2x large LED displays (each with a UNO), and a RS232 thermal printer.

It kept a daily tally of items, sales and other totals.

So it is possible.
The project description without code is in here as a series of tutorials.
LINK HERE

Hi @engrshoukat99 ,

Welcome to the forum..

not sure what's wrong so i made a few small changes..
can't test it though, sorry..

hope it helps..

#include <Arduino.h>
#include <Wire.h>

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);

#define BTN_PIN 6


struct SaleItem {
  char Code[13];
  char ItemName[10];
  float Price;
  int   Sold;
};

SaleItem Items[3] {
  {"2C007CC3D546\n", "Butter\n", 10.00, 0},
  {"0400C2D7C9D8\n", "Milk\n", 20.00, 0},
  {"0400BC5B29CA\n", "Pencil\n", 5.00, 0}
};



char input[20];
int count = 0;

byte btnState = 1;
byte lastBtnState = 1;
unsigned long lastPress = 0;
unsigned long debounceInterval = 50;


float total = 0.00;

void setup ()
{
  Serial.begin(9600);

  pinMode(BTN_PIN, INPUT_PULLUP);

  lcd.init();
  lcd.backlight();
  Wire.begin();


  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()
{

  unsigned long now = millis();


  //dbounce button/switch..
  if (now - lastPress >= debounceInterval) {
    byte btn = digitalRead(BTN_PIN);
    if (btn != btnState) {
      lastPress = now;
      btnState = btn;
    }
  }

  //read a byte if ready
  if (Serial.available()) {
    byte b = Serial.read();
    if (b != 10){
    input[count] = b;
    count++;
    }
  }

  //if we have all 12 bytes..
  if (count == 12) {
    //null terminate
    input[count] = '\n';
    //loop thru items looking for a mtach..
    for (int i = 0; i < sizeof(Items); i++) {
      if ((strncmp(input, Items[i].Code, 12) == 0) && (btnState)) {
        //got a mtach
        lcd.setCursor(0, 0);
        lcd.print(Items[i].ItemName);
        lcd.print(" Added       ");
        lcd.setCursor(0, 1);
        lcd.print("Price :- ");
        lcd.print(Items[i].Price);
        lcd.print("      ");
        Items[i].Sold++;
        delay(2000);
        total = total + Items[i].Price;
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Total Price :-");
        lcd.setCursor(0, 1);
        lcd.print(total);
        delay(2000);
        break;
      }
    }

    count = 0;

  }

}

good luck.. ~q

1 Like

send me a full list of goods, I will calculate and send you the total price.

1 Like

Runs after I add

int count_prod1 = 6;
int count_prod2 = 7;
int count_prod3 = 8;

The button doesn't do anything, should it?

Oh, maybe it inhibits adding an item.

@qubits-us code does the same, in this case that is all and what the button does.

a7

thank you dear....your programming is working 90% right...i tried....there is little bit negligence...lcd display showing the item names, price, total correctly...but it is not showing on serial monitor....if you add some changes in same programming for serial monitor display...than it will be finalized for me....because i need lcd display including serial monitor display...thanks

one more thing i want to tell you....that i am not using any button in this project...directly i scan the RFID card with EM18 reader....and showing the results...so if you donot include button commands in prog...it will be ok....main probem is, it must show the results on the serial monitor....

again thanks for your assisting in program dear....i need some more changes according to serial monitor display....i hope you can suggest me...thanks

strange, you never had any Serial.prints in your orig sketch..
figured you had some type of reader attached to the port..

if you want to add some serial prints and you're sure it wont interfere with your reader..

you want the total to print when it updates the lcd add..
Serial.println(total);
just after the lcd.print(total);
should be simple enough..

have fun.. ~q

If you read and understand how the program works, you should have no problem. adding some serial prints.

If not, get to work studying the code until you can explain it
,

According to your code, I assume that your EM18 reader is connected to pins 0 and 1.
In this case, you cannot use the Serial Monitor on the PC to display messages, because the Arduino Uno/Nano board has only one Serial port and it is already occupied by the RFID reader.
You need to free pins 0 and 1 to use the Serial Monitor - for this you need to connect the RFID to other pins using the SoftwareSerial library.

See the link below as an example of the connecting EM18 module via SoftwareSerial.

brother....lot of thanks...actually i am new in this work...thats why felt difficulties...however thanks for your solution...now lcd and also serial monitor all are working properly... with your assistance felt good for this platform...

in future if i feel difficulty ...will contact you dear ...can you share me your email....?

Thanks brothers....whoever suggested me solution points for my problem... i am also thankful to this platform who gave us brilliant peoples to solve the problems regarding Arduino programing and automation projects.