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.
Step 1: Parts and toools
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)
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
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.
We recommend EasyEDA for electronic circuit design.
From Schematic Drawing to PCB Production, Just Need One Tool
Cheap PCB Prototype: 10 pcs 2 layers only $10, quick delivery, 100% E-test