🛒 Build a Magic Shopping Cart! 🪄
An Arduino & RFID Adventure for Young Makers!
Hey little makers! 👋 Ever wished your toy shopping cart could recognize what you put inside and tell you the total price — just like a real store checkout? Today we're building exactly that using an Arduino UNO and a bit of RFID magic (think of it as a secret ID card for your toys)!
🧰 What You'll Need
- 🟦 Arduino UNO
- 📡 RFID Reader Module (RC522)
- 🏷️ RFID Tags/Cards (one for each item)
- 📺 16x2 LCD Display (with I2C module)
- 🔌 Jumper Wires
- 🧩 Breadboard
- 🔋 9V Battery (optional)
✨ The Big Idea
Every toy or item gets its own special RFID sticker — like a fingerprint! 🖐️ When you tap the item near the RFID reader, the Arduino "recognizes" it, looks up its price, adds it to the total, and shows everything on a little screen. Just like magic! 🪄✨
🔌 Step 1: Connect the RFID Reader
Connect the RC522 RFID reader to your Arduino UNO like this:
🖥️ Step 2: Connect the LCD Screen
Using the I2C version of the 16x2 LCD makes wiring super easy:
- SDA → A4
- SCL → A5
- VCC → 5V
- GND → GND
🧠 Step 3: How the Code Thinks
Here's the simple plan our Arduino brain follows:
- Wait for an RFID tag to be tapped 👉
- Read its special ID number (UID) 🔍
- Match the UID to a toy/item name and price 🏷️
- Add the price to the running total ➕
- Show the item name and total on the LCD screen 📺
💻 Step 4: The Code
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>
MFRC522 rfid(10, 9);
LiquidCrystal_I2C lcd(0x27, 16, 2);
float total = 0;
void setup() {
SPI.begin();
rfid.PCD_Init();
lcd.init();
lcd.backlight();
lcd.print("Magic Cart Ready!");
}
void loop() {
if (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) {
String uid = "";
for (byte i = 0; i < rfid.uid.size; i++) {
uid += String(rfid.uid.uidByte[i], HEX);
}
if (uid == "a1b2c3") {
total += 10;
lcd.clear();
lcd.print("Apple +10");
}
else if (uid == "d4e5f6") {
total += 20;
lcd.clear();
lcd.print("Choco +20");
}
lcd.setCursor(0, 1);
lcd.print("Total: ");
lcd.print(total);
rfid.PICC_HaltA();
delay(1000);
}
}
🎮 Step 5: Let's Play "Shopping Time"!
Now for the fun part! 🎉 Give each kid a few toy items, each with its own RFID tag stuck on. Let them tap each toy near the reader — watch the LCD screen light up with the item name and the total price growing higher and higher, just like a real checkout counter!
🚀 Level Up Your Cart!
- 🔊 Add a buzzer that goes "beep!" every time an item is scanned
- 🟢🔴 Add LEDs: green light if total is under budget, red if it goes over
- 🧾 Print a "receipt" message at the end showing everything bought
🏷️ Step 6: Set Up Your Toy Price List
Before the magic happens, scan each RFID tag once using a simple test sketch and write down its special ID number (called a UID). Then make a little list — like a toy store menu! 🍫🧴🖊️
Type these into the item_list[] part of the code — that's your cart's "toy dictionary"! 📖
🔘 Step 7: Add the Magic Buttons
Our Magic Cart has three super buttons to control shopping:
- ➕ ADD button — switches to "putting items in" mode
- ➖ REMOVE button — switches to "taking items out" mode (changed your mind? no problem!)
- 🔄 RESET button — clears the bill and starts a brand-new shopping trip
Wire each button between its pin (D2, D3, D4) and GND. When pressed, the LCD shows a friendly message so you always know what mode you're in!
🔍 How the Magic Cart Thinks (Behind the Scenes)
Here's the secret journey of every scan, step by step:
- 🏷️ Tag Detected: The RC522 reader senses a tag within about 5cm and reads its UID using the SPI connection.
- 🔎 UID Lookup: The Arduino checks its
item_list[]"toy dictionary" to find a match. - 💰 Bill Updated: Found a match? The price is added (or removed) from the running total.
- 📺🔔 Feedback Time: The LCD shows the item and new total, and the buzzer beeps once to say "Got it!"
🖥️ Bonus: Try It Without Any Hardware!
Don't have the parts yet? No worries! You can test the whole Magic Cart online using Wokwi, a free browser-based simulator:
- Start a new Arduino UNO project on Wokwi
- Paste in the circuit setup (diagram.json)
- Paste in the Arduino code
- Press ▶️ Play
- Click the on-screen RFID cards to simulate scanning!
It's a great way to test your code before building the real thing! 💻
❓ Fun Questions Kids Often Ask
Q: Why can't I connect the RFID reader to the 5V pin?
A: The RC522 module is delicate and only likes 3.3V power. Giving it 5V is like giving your hamster a giant burger — too much, and it could break! Always use the 3.3V pin. ⚠️
Q: What if my buttons act weird or scan twice by accident?
A: That's called "noise"! Adding a small pull-down resistor (10kΩ) between the button and GND helps keep things calm and accurate. 🧘
Q: How do I find my LCD's address?
A: Run a tiny "I2C scanner" sketch — it will tell you if your screen's address is 0x27 or 0x3F. Update that number in your code. 🔢
🎉 Why This Project Rocks!
This project teaches kids about electronics, coding logic, and even budgeting — all while playing a fun shopping game! It's the perfect weekend STEM adventure for curious young minds. 🤖💡
Happy building, little engineers! 🔧✨
Comments
Post a Comment