Vending Machine Using Arduino

by YTheBuilder in Circuits > Arduino

30 Views, 0 Favorites, 0 Comments

Vending Machine Using Arduino

Screenshot 2026-01-21 at 6.56.23 PM.png
Screenshot 2026-01-21 at 6.52.38 PM.png
Screenshot 2026-01-21 at 7.17.10 PM.png

Hello everyone! My name is Yash and in this instructable, I will be showing you step by step, how to make a Vending Machine using an Arduino yourself and also presenting my final project. For this project, I have created a Vending Machine. This idea came to my mind because I am really into crafts and love to the concepts of vending machines, the mechanics of it, and how you can get a snack instantly from a "box". So I figured, why not make it with some hardware components and an Arduino. This is going to be a vending machine that replicates a real vending machine.

How it works:

Just like a real vending machine, the user is displayed the message "Make Payment" on the LCD screen, which then the user can make a "payment" by using their card and tapping it to the card reader - which in this case is an RFID. The payment will then go through and display "Approved" on the screen. This will now allow the servo arm to rotate which would dispense the candy that would be inside. Now that you have the gist of it and some information on what this project is all about, let's get into what materials are needed.

Supplies

image.png
Screenshot 2026-01-21 at 8.10.04 PM.png

For this Project you will need the following materials:


Materials ----------------- Quantity

LCD....................................................1

555 timer.........................................1

Servo................................................1

Wires.............................................depends (I used about 30)

Breadboard.....................................2

RFID.................................................1

LED’s................................................6

CD4017.............................................1

330Ω resistor.................................1

1k resistors....................................2

10uf Capacitor...............................1

1N4148 Diodes...............................1

Arduino...........................................1

Empty plastic water bottle........1

Cardboard....................................depends

Tape..............................................depends


Total Cost: $66.70 CAD

Wiring RFID, LCD & Servo

Screenshot 2026-01-21 at 7.22.33 PM.png
Screenshot 2026-01-21 at 7.22.39 PM.png
Screenshot 2026-01-21 at 7.24.15 PM.png
Screenshot 2026-01-21 at 7.17.10 PM.png

1) Wiring RFID

Connect the RFID with Male to Female Wire.

Connect...

RFID Pins ----- Arduino Pins

SDA pin -------------Pin 10

SCK pin -------------Pin 13

MOSI pin------------Pin 11

MISO pin------------Pin 12

RST pin--------------Pin 9

GND-----------------GND

VCC------------------3.3V


2) Connect Breadboard to Arduino

Take a wire and connect 5v from the Arduino and connect it to the positive rail of the breadboard. Make sure to insert a wire connecting GND from one side of the breadboard to the other side on the breadboard so that current can go throughout and we can make connections for the other components.


3) Connecting/Wiring Servo

Take a wire and connect it to any positive rail on the breadboard getting power. Take the others side of that wire and connect it to the power (VCC) of the servo motor. Now take another wire and connect it to the ground (negative) rail on the breadboard, connecting the other side of the wire to the GND of the servo. Next, connect a wire from the signal of the servo and connect it to Pin 3 of the Arduino.


4) Wiring LCD

Now lets wire the LCD screen! You will need to use a Male and Female wire for this step (you could also use normal wires here, but will have to make the connection to the pins of the LCD).

Start by connecting GND of the LCD to the GND (negative) in the breadboard. Next, Connect the VCC of the LCD to the VCC (Positive) in the breadboard. Now, connect SDA pin of LCD to A4 pin on the Arduino and SCL to A5 pin on Arduino.

Making the Vending Machine - Box

Screenshot 2026-01-21 at 7.28.40 PM.png
Screenshot 2026-01-21 at 7.28.46 PM.png
Screenshot 2026-01-21 at 7.28.51 PM.png
Screenshot 2026-01-21 at 7.32.19 PM.png
Screenshot 2026-01-21 at 7.30.42 PM.png
Screenshot 2026-01-21 at 6.56.23 PM.png

Now that the RFID, Servo and LCD are all wired up, now its time to physically make the vending machine!


To make the physical vending machine, you will need any shoe box or cardboard (make into a box shape). Place the components onto the box to design the vending machine to your liking (i.e where you want to put each component), and mark out the components on the box. Make sure to also cut out a small hole in the box beside where you plan to place the Arduino so you can run the Arduino wire through the box to access your computer. Now cut out the cardboard pieces to make the components fit. Once you get all the components to fit perfectly, you can secure them down with pieces of tape.

At the top of the vending machine (box), make a cut out for your empty water bottle - this is where you will place your snacks and will dispense from. Cut the top part of your plastic bottle and make it fit to size to the hole on the box you just made. Under the circle cut, make a ramp out of cardboard and glue it on an angle to where the items can be picked up - make a door cut out for the spot where users can collect their snacks. In addition, cut out a small square or shape (enough to cover the opening of the bottle that you just cut) and tape it to the arm of the servo - this will act as a lever (image 4). This will sit under the bottle and allow for snacks to only fall when the payment gets approved.


Optional: You can also make a border around the cut outs to make the vending machine visually appealing


Look at the Image above to confirm your placement is correct.


Reference to where all components are placed (refer to image above):

Top right: LCD

Under LCD: RFID

On the left (big cut out): Is the "glass" to where users can look inside. Tape your servo on the roof inside of the box - making sure the lever covers the open bottle.

Under big cut out: Door/chute for snack pick up.

Making Pulsing Lights

Screenshot 2026-01-21 at 7.31.42 PM.png
Screenshot 2026-01-21 at 7.31.47 PM.png
Screenshot 2026-01-21 at 7.31.51 PM.png
Screenshot 2026-01-21 at 7.31.59 PM.png
Screenshot 2026-01-21 at 7.32.03 PM.png
Screenshot 2026-01-21 at 7.32.42 PM.png
Screenshot 2026-01-21 at 7.35.50 PM.png
Screenshot 2026-01-21 at 7.38.25 PM.png
Screenshot 2026-01-21 at 7.39.17 PM.png
Screenshot 2026-01-21 at 7.39.26 PM.png

Make sure you have done the following from step 2 before moving on:

1) Have all components wired up

2) All components are fitted on the vending machine


If you have done all this, Great!

-------------------------------------------------------------------------------------------

Now, for the vending machine you have to make the pulsing lights. The purpose of this is for many reasons, one being it grabs users attention and also provides light to the vending machine itself. This is essentially an Led Chaser.

To build this LED chaser take your second breadboard, and place a 555 timer on the board (like so in the photo). Just a couple rows beside that, place a CD4017 on the board. The 555 Timer will act as a clock which would be generating regular pulses. On the other hand, the CD4017 Decade Counter will receive these pulses and one after another activate its outputs - lighting up LEDs one by one to create the chasing light effect.


Set up

Connect a wire from the negative rail of the breadboard to pin 1 of the 555 (GND). Do the same for the 4017 to pin 8. Now Connect a wire from the positive rail and connect it to pin 8 of the 555 and another one to pin 16 of the 4017.


555 Timer Connections

  1. Connect a wire from pin 2 to pin 6.
  2. Connect a wire from pin 4 to pin 8
  3. A 1k resistor from pin 2 to pin 7
  4. A 1k resistor from pin 8 to pin 7
  5. Insert a 330Ω resistor from negative rail to the spot beside pin 1 (to the left)
  6. 10uf Capacitor from negative rail to pin 2
  7. connect pin 3 (555 timer) to pin 13 (4017)

CD4017 Connections

  1. pin 8 to pin 15
  2. pin 8 to pin 13


Connections to the LED's (from 4017)

LED 1

Insert a jumper wire into pin 3 and a few rows below the CD4017 - this is the path to the first LED. Insert a 1N4148 diode in the same row as the jumper wire (the anode is facing the jumper wire). Insert a LED in the same row as the diode and the negative rail (the cathode is in the negative rail).

LED 2

Now insert a jumper wire into pin 2 and a few rows below the first diode (this is the path to the second LED), also insert a diode in the same row as the jumper wire, the anode is facing the jumper wire. Again, insert a LED in the same row as the diode and the negative rail with the cathode in the negative rail.

LED 3

Insert a jumper wire into pin 11 and the same row as the second diode - this is the path of the LED moving in the reverse direction. Now, we are going to connect the third LED. Insert a jumper wire into pin 4 and a few rows below the second diode insert a diode in the same row as the jumper wire. Insert a LED in the same row as the diode and the negative rail.

LED 4

Insert a jumper wire into pin 9 and the same row as the third diode. Insert a jumper wire into pin 7 and a few rows below the third diode. Insert a diode in the same row as the jumper wire. Insert a LED in the same row as the diode and the negative rail.

LED 5

Insert a jumper wire into pin 6 and the same row as the fourth diode. Insert a jumper wire into pin 5 and a few rows below the fourth diode. Insert a diode in the same row as the jumper wire. Insert a LED in the same row as the diode and the negative rail.

LED 6

Insert a jumper wire into pin 10 and the same row as the fifth diode. Insert a jumper wire into pin 1 and a few rows below the fifth diode. Insert a diode in the same row as the jumper wire. Insert a LED in the same row as the diode and the negative rail. Insert a 470-ohm resistor into the negative rail and the middle of the breadboard. Insert a jumper wire into the same row as the resistor and the negative rail.


To make this LED chaser, I also found a video which you could follow: Click Here


NEXT

Once your LED chaser is made and working, cut out a small rectangle (enough so that you can see the LED's peaking out. You can tape this breadboard setup vertical beside the ramp (on the left) - taping it to the front of the box on the inside. The power and ground for this second circuit can be either connected to the first breadboard on the side, or can be supplied power and ground through a 9v battery (choice is yours).


Reference

https://www.youtube.com/watch?v=cmsSjqV_m4s

Coding

Screenshot 2026-01-21 at 8.37.38 PM.png
Screenshot 2026-01-21 at 6.17.48 PM.png

The coding for this Vending Machine will be for the following components of the machine: LCD, RFID and Servo.


For this project and code to work, you will need to download the following libraries for the servo, LCD and RFID to work. These libraries can be downloaded straight from the Arduino website or from GitHub (links provided below).


Libraries Required:

  1. SPI --------> Communication protocol for microcontrollers
  2. MFRC522 -------> For the RFID
  3. Servo --------> For the Servo
  4. LiquidCrystal_I2C ---------> For the LCD


Important

Once you download the code and upload it to Arduino, you will need to open the serial monitor. When you open the serial monitor, you will see a message that states "Put your card to the reader...", when you see this, place the card that you will use for the "payment" system (this card comes with the RFID). Once you place the card on the reader, you will get the UID tag (which is the "access code" for the specific card that was placed on the reader). Now take UID, and place it in the line where it states "card that gets access for gate" (you can make sure you placed it in the right place by confirming with the image provided above). After you place your UID, upload the code once again. Once you upload the new information in the code, your Vending Machine should work - tapping the card will now move the servo and dispense candy.


I will provide the code for this project Below

Stock Your Candy!

Screenshot 2026-01-21 at 7.40.17 PM.png

The only thing left now, is stocking candy/snacks in your "dispenser" (the plastic bottle).


Congrats, you have now successfully made your own Vending Machine using an Arduino, Arduino Software, a 555 timer and CD4017!


Enjoy Vending!