Cookies adminitrator box [Electronics only] using arduino

At home the cookies disappear relatively fast. ¿Why? Well, principally because of me and my father. That’s why my mother and my sister have to hide some to eat them later. It’s embarrassing, I know, but it’s because we are like “Oh, I want to eat a cookie”, and some time later “I will eat another”, and so on, and when we realize, we have eaten more than a half of the cookies. That’s why I decide to make this box, to correctly administrate them.
Cookies adminitrator box [Electronics only] using arduino

The interface of the box have some pushbuttons, one rgb LED and a LCD screen. Normally, the LED is blue (to show that the box is working) and the LCD display the message “x of y cookies. z have no owner”, where x is the actual amount of cookies, y is the original amount of cookies and z is the number of cookies that leftover.

Every user have one button, so when I press my button, the box check if I have any cookies left, and if I have, opens the door, turn the LED green, and in the LCD shows “You have x cookies left”. After a while (5 seconds), it closes the door again. If I haven’t any cookie, the LED turn red and the LCD say’s “You have no cookies left :(” and the door stay closed.

When the box is empty (maybe it’s not empty at all, but there’s no cookies left for any of the users), the LED turns red, the LCD show’s the message “The box is empty!” and the door opens.

Here’s a demo:

Here I leave a zip file with the schematics and the code.

cookie-box.zip313 KB

Step 1: Parts and toools

For this project you will need:


4 Pushbuttons (Normally open)
4 10K Ohm resistors (for the buttons, more about this in the next step)
3 330 Ohm resistors (for the LED. Any value bethween 220 Ohm and 1k Ohm must work right)
1 RGB LED (common cathode)
1 10k potentiometer
1 16X2 LCD screen
1 Servo (I used the TowerPro SG92R which I had at hand. The servo you will need depends on your box)
1 Arduino (I used an UNO r3)
1 box


A working pc with the Arduino IDE
USB cable to upload the sketch
A power supply between 7 and 12 volts with relatively high amperage*

*Mine supplies 500mA, which seems to be low, because the box don’t work. I had to connect it to both, my computer and the power supply

Step 2: Hardware

The conections in the pictures are a mess, so here I leave you the Fritzing “draw” and the schematic. I think the “draw” it’s pretty clear, but the schematic seems to be a liitle more complicated, so, just in case, in the conections, just the “doted” lines are joints.

I think the servo and the LED conections are self explanatory, but I’ll explain them anyway. The servo is powered with 5V from the Arduino, and is connected to the 13rd pin of the Arduino. The RGB LED have a longer leg. That one is the cathode. At the left of the cathode it’s the “red leg” and at the right are the green and blue (In that order). The cathode is conected to negative and the three other legs are conectet to the Arduino with 330 Ohm resistors (the cable colors shows the LED color that turns on/off).

Cookies adminitrator box [Electronics only] using arduino schematic

All the buttons have the same connection. One side is connected to 5V, the other to the Arduino and to GND with a 10k resistor. The resistor help to make the signal equal to LOW when the button it’s not pressed. The resistors are not necessary, but help to make the LOW signal concrete.

The LCD it’s used in 4-bit mode, to save some pins.

Here’s the pin explanation of the LCD, from the Arduino LCD Twitter display, I found it very clear and useful:

Pin 1. Ground
Pin 2. VCC (+5V)
Pin 3. Contrast
Pin 4. Register Select (RS)
Pin 5. Read/Write (R/W)
Pin 6. Clock
Pin 7. N/A
Pin 8. N/A
Pin 9. N/A
Pin 10. N/A
Pin 11. Bit 4
Pin 12. Bit 5
Pin 13. Bit 6
Pin 14. Bit 7
Pin 15. Backlight Anode (+)
Pin 16. Backlight Cathode (-)

The potentiometer manages the contrast of the LCD.

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.

Follow Us:
Scroll to Top