#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
char input[12];
int count = 0;
int count1 = 0;
int count2 = 0;
int count3 = 0;
int check = 0;
int check3 = 0;
int check2 = 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 = 1;
void setup ()
{
lcd.init();
lcd.backlight();
Wire.begin();
Serial.begin(9600);
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()
{
count = 0;
while (Serial.available() && count < 12)
{
input[count] = Serial.read();
count++;
delay(5);
}
int a = digitalRead(6);
if ((strncmp(input, "2C007CC3D546", 12) == 0) && (a == 1))
{
lcd.setCursor(0, 0);
lcd.print("Butter Added ");
lcd.setCursor(0, 1);
lcd.print("Price :- 10.00 ");
p1++;
delay(2000);
total = total + 10.00;
count_prod1++;
lcd.clear();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Total Price :-");
lcd.setCursor(0, 1);
lcd.print(total);
}
if ((strncmp(input, "0400C2D7C9D8", 12) == 0) && (a == 1))
{
lcd.setCursor(0, 0);
lcd.print("Milk Added ");
lcd.setCursor(0, 1);
lcd.print("Price :- 20.00 ");
p2++;
delay(2000);
total = total + 20.00;
count_prod2++;
lcd.clear();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Total Price :-");
lcd.setCursor(0, 1);
lcd.print(total);
}
if ((strncmp(input, "0400BC5B29CA", 12) == 0) && (a == 1))
{
lcd.setCursor(0, 0);
lcd.print("Pencil Added ");
lcd.setCursor(0, 1);
lcd.print("Price :- 5.00 ");
p3++;
delay(2000);
total = total + 5.00;
count_prod3++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Total Price :-");
lcd.setCursor(0, 1);
lcd.print(total);
}
}
moderator edit: code tags added
This isn’t a beginner project, but either way, you’ll need a processor with enough memory, a storage / data capacity to hold all your inventory items etc,
Possibly an ESP, or more, ideally something with more storage and supporting a file system and small DB if you have a lot of data items.
If you’re intending to stay with a small processor, you could your item data in an array of structs.
kolaha
September 4, 2024, 4:54am
4
from what it reads? is it zero ended or "\r\n" ?
Hello engrshoukat99
I made a quick and short code review and I can only recommend to study the object oriented programming for this project.
b707
September 4, 2024, 5:43am
6
The C language standard is a null-terminated string; so I would recommend you to add an additional element to input array.
a == 1 this is used for to add item
ok...thanks bro....can you suggest me programming for mentioned problem of project
yes brother...i checked this...lcd display shows the item name and price....but serial monitor does not show anything.
dear...i didnot get your meaning....because with that programming lcd display shows the RFID card with name...only problem is that...it is not showing total price if i add second or third item....
kolaha
September 4, 2024, 6:15am
12
here you are:
#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
char input[12];
int count = 0;
int count1 = 0;
int count2 = 0;
int count3 = 0;
int check = 0;
int check3 = 0;
int check2 = 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 = 1;
void setup ()
{
lcd.init();
lcd.backlight();
Wire.begin();
Serial.begin(9600);
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()
{
count = 0;
while (Serial.available() && count < 12)
{
input[count] = Serial.read();
count++;
delay(5);
}
int a = digitalRead(6);
if ((strncmp(input, "2C007CC3D546", 12) == 0) && (a == 1))
{
lcd.setCursor(0, 0);
lcd.print("Butter Added ");
lcd.setCursor(0, 1);
lcd.print("Price :- 10.00 ");
p1++;
delay(2000);
total = total + 10.00;
count_prod1++;
lcd.clear();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Total Price :-");
lcd.setCursor(0, 1);
lcd.print(total);
Serial.println(total);
}
if ((strncmp(input, "0400C2D7C9D8", 12) == 0) && (a == 1))
{
lcd.setCursor(0, 0);
lcd.print("Milk Added ");
lcd.setCursor(0, 1);
lcd.print("Price :- 20.00 ");
p2++;
delay(2000);
total = total + 20.00;
count_prod2++;
lcd.clear();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Total Price :-");
lcd.setCursor(0, 1);
lcd.print(total);
Serial.println(total);
}
if ((strncmp(input, "0400BC5B29CA", 12) == 0) && (a == 1))
{
lcd.setCursor(0, 0);
lcd.print("Pencil Added ");
lcd.setCursor(0, 1);
lcd.print("Price :- 5.00 ");
p3++;
delay(2000);
total = total + 5.00;
count_prod3++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Total Price :-");
lcd.setCursor(0, 1);
lcd.print(total);
Serial.println(total);
}
}
Now you’re catching up a bit, take another read of post #2 to combine what you picked up.
An array of structs will help your data scheme a lot.
kolaha
September 4, 2024, 6:18am
14
try dtostrf()
for floating point numbers
exactly serial monitor does not show...only lcd display show
kolaha
September 4, 2024, 6:26am
16
mark post #12 as solution
dear still not reached at solution...it will be better for me if you send me complete program as you are suggesting...i will try.thanks
b707
September 4, 2024, 7:28am
19
Your code doesn't print a single line on Serial Monitor. What do you expecting from it?
Please answer the questions:
Where does the RFID number come from in your program?
Are you using some RFID reader connected via serial?
What kind of Arduino do you have and to what pins is the RFID module connected?
sonofcy
September 4, 2024, 12:28pm
20
You need to do at least a 2 yr program in data processing.
hammy
September 4, 2024, 12:38pm
21
iMO this is not a Arduino project . I would looking at a spreadsheet and using Macro’s /VBA etc to give the functionality you desire .