Introduction: Electronic Piggy Bank

This Electronic Piggy Bank project will guide you through the steps to build the necessary circuit/connections needed. You will need the following parts.

  • 5V Relay

  • 2 LEDs (Red and Green)

  • 2 330 Ohm resistors

  • Male/Female wires

  • Regular colored wires

  • Arduino Uno & Data Cable

  • RFID key and sensor

  • Passive Buzzer

  • Servo Motor

  • Box

  • Breadboard

The box will serve as the actual piggy bank, for the one in this example I used a glue gun to piece together pieces of cardboard.

Step 1: Wiring Connections

In this step you will learn where to plug in each and every wire on the breadboard and Arduino

RFID Sensor:

  • VCC = 3.3 V
  • RST = Pin 2
  • GND = GND
  • MISO = Pin 3
  • MOSI = Pin 4
  • SCK = Pin 5
  • NSS = Pin 6
  • IRQ = Pin 7

Relay:

  • VCC = 5 V
  • GND = GND
  • SIG = Pin 8

Servo Motor:

  • VCC = 5 V
  • GND = GND
  • SIG = Pin 9

Passive Buzzer:

  • VCC = 5 V
  • GND = GND
  • SIG = Pin 10

Green LED:*

  • VCC = Pin 11
  • GND = GND

Red LED:*

  • VCC = Pin 12
  • GND = GND

*For LEDs make sure you have a resistor between the power and the LED in order to prevent breaking the LED

Step 2: Code

The code for this project while seemingly complicated it basically comes down to IF the card ID is read THEN turn on/off LEDs, Buzzer, and rotate Servo.

Download the libraries needed for this project at https://www.sunfounder.com/learn/category/rfid-kit... just press the download button and put those files in the libraries folder.

Now make sure you have the right COM port and board selected in the Arduino IDE and upload. If you experience any issues the most likely issue is a misplaced wire so make sure everything in the right place and nothing disconnected.

Every RFID key tag is different so what you want to do is first swipe your card and check the serial monitor to read the card ID, then you must replace the IF statement conditions with that ID in this fashion:

Example ID: 5AE4C955

Condition: id[0]==0x5A && id[1]==0xE4 && id[2]==0xC9 && id[3]==0x55


There is LCD display code if you want to add an LCD to the project, just a heads up that the code will not work unless that code is included even if you aren't using an LCD



Step 3: Box

As mentioned earlier, my box was created using cardboard and hot glue, I cut out a square in the roof of the box for the cover and the servo motor, I put the servo in place by first wrapping parts in hockey tape (any tape will do) and hot gluing the tape to create a sort of hard shell so I don't ruin the parts so i can just peel the tape off later.

The box is fully enclosed except the back side where the connections come from, I left a window 1/3 the area of that back side and left a little flap of cardboard at the bottom to get coins out with ease.

Step 4: Final Product