Summary of Cookies adminitrator box [Electronics only] using arduino
The author built an automated cookie dispenser to prevent family members from overeating cookies. The Arduino-based box tracks remaining cookies, identifies users via pushbuttons, and controls a servo door. It features an RGB LED for status indication (blue for active, green for access, red for errors or empty) and an LCD screen displaying real-time cookie counts and ownership details.
Parts used in the Cookie Administrator Box:
- 4 Pushbuttons (Normally open)
- 4 10K Ohm resistors
- 3 330 Ohm resistors
- 1 RGB LED (common cathode)
- 1 10k potentiometer
- 1 16X2 LCD screen
- 1 Servo (TowerPro SG92R or similar)
- 1 Arduino UNO r3
- 1 box
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
Parts:
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
Tools:
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*
Protoboard
Jumpers
*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
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).
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.
- How does the box determine if a user can take a cookie?
The system checks if the specific user has any cookies left; if yes, it opens the door and turns the LED green. - What happens if a user presses their button but has no cookies left?
The LED turns red, the LCD displays a sad message stating they have no cookies left, and the door stays closed. - What is the default color of the RGB LED when the box is working normally?
The LED is blue to indicate that the box is functioning correctly. - How long does the door remain open after a successful request?
The door opens for approximately 5 seconds before closing again automatically. - What occurs when the box is completely empty for all users?
The LED turns red, the LCD shows "The box is empty!", and the door opens. - In what mode is the LCD screen configured to save pins?
The LCD is used in 4-bit mode. - Why are 10k resistors used with the pushbuttons?
The resistors ensure the signal equals LOW when the button is not pressed, making the signal more concrete. - Which pin connects the servo motor on the Arduino?
The servo is connected to the 13th pin of the Arduino.
