For this week’s assignment, I am creating a Sadaqa (Charity) Coin Box using Arduino.
The box will have the following features:
Coin Detection: An IR sensor will detect when a coin is inserted into the box.
Feedback: A buzzer will sound to acknowledge the coin insertion, providing a satisfying interaction for the user.
Opening Mechanism: A push button will trigger a servo motor to open the box, allowing access to the coins inside.
Why I Care About This Idea
I care about this idea because it combines technology, creativity & social good. The Sadaqa Coin Box is designed to encourage children to participate in charitable acts by making the process fun and interactive. By using simple electronics and a playful design, I hope to inspire children to develop a habit of giving and doing good deeds.
Teaching children about Sadaqah from an early age is crucial because:
Building Good Habits: Children are like sponges; they absorb habits and values quickly. Introducing them to Sadaqah early helps instill generosity and empathy as core values.
Understanding Barakah: When children see the positive outcomes of their actions (e.g., helping others, feeling good about giving), they begin to understand the concept of barakah in a tangible way.
Connection to Faith: Sadaqah is a practical way to connect children to their faith. It helps them see Islam as a way of life that promotes kindness, sharing, and community service.
Fun and Interactive Learning: By creating a Sadaqa Coin Box that is interactive and engaging, children are more likely to enjoy the process of giving. The buzzer and servo motor add an element of excitement, making Sadaqah feel like a rewarding activity rather than a chore.
Why This Project Matters
This Sadaqa Coin Box project is more than just a technical assignment; it’s a tool to teach children the importance of charity in a fun and memorable way. By combining technology with Islamic values, we can create a generation that is not only skilled in innovation but also deeply rooted in compassion and generosity.
Inspiration
The idea was inspired by:
Traditional Sadaqa Boxes: These are commonly used in many cultures to collect donations for charitable causes. I wanted to modernize this concept by adding interactive elements.
Interactive Toys for Children: Many children’s toys use sound and motion to engage users. I wanted to incorporate similar features to make the coin box more appealing to kids.
Software:
Tinkercad – Used for simulating the circuit before physical assembly to ensure functionality.
Arduino IDE – Used for coding and uploading the program to the Arduino Uno to control the components.
Electronic Components for Testing the Circuit:
Breadboard – To prototype and test the connections before finalizing the wiring.
Arduino Uno – The microcontroller to process inputs and control the system.
IR Sensor – Detects when a coin is inserted and triggers the buzzer.
Buzzer – Provides an audio signal when a coin is detected.
Push Button – Used to open the box by activating the servo motor.
Servo Motor – Controls the locking mechanism by rotating when the button is pressed.
Materials for the Physical Box:
Cardboard – Used for constructing the body of the Sadaqah Box due to its lightweight and easy-to-cut properties.
Wood Sticks – Provides additional support and structure to the cardboard box.
Glue Gun – For strong and secure bonding of the cardboard parts.
Ruler – To measure and ensure precise dimensions.
Cutter & Scissors – For cutting cardboard accurately.
For this assignment, I followed a structured approach to design and implement the Sadaqah Coin Box using Arduino and electronic components.
Initial Wiring & Testing on Breadboard
I first designed the wiring in Tinkercad, not for simulation but to have a visual reference before implementing it on the actual breadboard. This helped me avoid wiring mistakes and made the connections more organized.
After that, I physically built the circuit on the breadboard, step by step:
I tested the IR sensor by placing an object in front of it and checking whether the buzzer produced a sound.
I then tested the servo motor, ensuring that when I pressed the first button, it rotated 90 degrees, and when I pressed the second button, it returned to 0 degrees.
Wiring Details:
IR Sensor:
- VCC -> 5V
- GND -> GND
- OUT -> Arduino pin 2
Buzzer:
- Positive (+) -> Arduino pin 3
- Negative (-) -> GND
Push Button:
- One leg -> Arduino pin 4
- Other leg -> GND (using internal pull-up resistor)
Servo Motor:
- Signal (S) -> Arduino pin 5
- VCC (Red) -> 5V
- GND (Black) -> GND
When a coin is inserted, the IR sensor detects it.
The buzzer plays a tune as an acknowledgment.
If the user wants to access the stored coins, they press the push button.
Pressing the button rotates the servo motor, opening the coin storage door.
Pressing it again closes the door, securing the coins.
Writing & Testing the Arduino Code
Once the wiring was done, I moved on to the Arduino IDE, where I wrote and uploaded the code to the Arduino board. The code controlled:
-The IR sensor, which detects coins.
-The buzzer, which gives an alert when a coin is detected.
-The servo motor, which opens and closes the coin storage door when the respective push button is pressed.
I used DeepSeek to assist in generating a base Arduino code, then modified and fine-tuned it according to my project's specific needs. After uploading the code to the Arduino, I tested each function multiple times to confirm that everything worked as expected.
1. Including Libraries
The Servo.h library is included to control the servo motor.
2. Pin Definitions & Variables
irSensorPin (Pin 2): Reads input from the IR sensor.
buzzerPin (Pin 3): Controls the buzzer for sound feedback.
buttonPin (Pin 4): Detects when the button is pressed.
servoPin (Pin 5): Controls the servo motor's movement.
myServo: Creates a servo motor object.
buttonPressed: Keeps track of whether the button is currently pressed (to prevent repeated actions).
servoPosition: Stores the state of the servo (open or closed).
coinDetected: Ensures that the buzzer only plays once per object detection.
3. Setup Function (setup())
pinMode(irSensorPin, INPUT); → Sets the IR sensor as an input.
pinMode(buzzerPin, OUTPUT); → Configures the buzzer as an output.
pinMode(buttonPin, INPUT_PULLUP); → Enables the internal pull-up resistor for the button, meaning it will read HIGH when not pressed and LOW when pressed.
myServo.attach(servoPin); → Links the servo to pin 5.
myServo.write(0); → Starts the servo at 0 degrees (closed position).
4. Loop Function (loop())
This section continuously runs, checking sensor inputs and triggering the appropriate actions.
Reads the IR sensor → If an object is detected (LOW state), it plays a buzzer tune.
coinDetected prevents repeated buzzing → The buzzer plays only once per detection.
Detects button press (LOW state) → Calls toggleServo() to move the servo.
Ensures single activation → The action runs only once per press.
5. Function to Play Tune (playTune())
Uses tone(pin, frequency, duration) to play a short melody.
The buzzer plays three different notes, then stops using noTone(buzzerPin).
6. Function to Toggle Servo (toggleServo())
Moves the servo motor between 0° (closed) and 90° (open) when the button is pressed.
Toggles servoPosition → If it's at 0°, it moves to 90° (and vice versa).
Final Preparations Before Fabrication
After confirming that the wiring and code functioned correctly, I finalized the layout of the components and prepared to mount everything inside the cardboard enclosure for the final assembly.
After successfully testing the circuit and ensuring all components functioned correctly, I proceeded with the implementation process as follows:
Optimizing the Circuit for Installation
To make the design more compact and mountable, I transferred the wiring onto a smaller breadboard, this allowed me to fit the electronics neatly inside the Sadaqah Coin Box.
Constructing the Cardboard Coin Box
I built the box structure using cardboard, ensuring a partition inside:
One section for the Arduino and breadboard.
The other for coin storage and the servo-operated door.
Mounting the Components
I fixed the Arduino inside the designated partition.
The small breadboard was placed next to it, containing the buzzer and wiring of the IR sensor, Servo motor and push button.
IR Sensor Positioning:
I used an extension wire to place the IR sensor on the partition, allowing it to detect coins as they enter the storage section.
Push Button Positioning:
Another extension wire was used to place the push button outside the coin box for easy access.
Servo Motor Placement:
The servo was installed at the coin storage door, programmed to rotate and open/close the door when the button is pressed.
Final Assembly
Using a glue gun, I securely sealed all cardboard sides to form a sturdy and functional Sadaqah Coin Box.
I ensured that all components were firmly fixed and that wires were properly routed to maintain a clean and organized setup.
This step-by-step process resulted in a working prototype that successfully detects coin entry, activates a buzzer, and opens/closes the storage door via a button press.
Sadaqah Coin Box
Title of Media
Receiving Feedback & Suggestions
I faced several issues with the IR sensor detecting unintended objects (e.g., the coin box edges) instead of just the coin entry.
I also encountered difficulties with the locking mechanism of the storage door.
I consulted my peers and received various suggestions to refine the sensor’s positioning and calibration and to improve the door mechanism.
Incorporating Someone Else’s Idea
My best friend contributed a brilliant idea regarding the servo mechanism, Instead of using an additional locking system, they suggested using the servo horn itself as the locking mechanism.
This made the design simpler, more efficient, and required fewer components.
I built upon this idea by adjusting the servo rotation angles to ensure a secure open/close motion.
Who/What I Turned To When Stuck
My first option was AI tools, as they provided quick responses for coding and circuit-related issues.
If I needed practical advice or real-world experience, I turned to experienced friends who had worked with similar sensors and components.
When things still weren’t working, I reached out to my instructor, Yassin, for expert guidance.
Pausing to Research & Learn More
During the coding phase, I had to pause multiple times to research:
Mistakes & Pitfalls Others Can Avoid
Relying solely on AI without verification: AI-generated code can be a great starting point, but I learned that testing and debugging manually is essential.
Assuming the sensor works perfectly after testing:
I tested the IR sensor before mounting it on the cardboard and it worked fine. However, after mounting, it either triggered the buzzer constantly or didn’t work at all.
This taught me that the sensor’s positioning and environment significantly affect its performance.
Switching components too quickly:
When the IR sensor caused issues, I switched to an ultrasonic sensor without fully understanding its limitations, It didn’t perform well for my specific use case, leading me back to the IR sensor.
Yassin advised me to add a potentiometer for calibration, but unfortunately, it didn’t solve my issue.
Eventually, I returned to my original setup with IR sensor, fine-tuned the code and made it work through trial and error.
Re-Allocating IR Sensor
Sadaqa Money Box Demo
Since my final project will also involve sensing wooden coins entering, this week’s assignment served as a great trial run for using the IR sensor effectively.
I now understand how to position the IR sensor correctly to ensure accurate detection, avoiding the issues I faced with false triggering.
This experience also helped me learn how to fine-tune the Arduino code for better responsiveness and avoid unnecessary buzzer activations.
Additionally, I gained confidence in wiring and organizing components neatly inside a confined space, which will help when designing my final project’s enclosure.
Honestly, there wasn’t anything particularly cool that I built this week, but there was definitely a moment I’ll never forget 😁
During the offline session, we were divided into teams to create a smart home project, and I was working with Youssef, While connecting the 9V adapter to the Arduino, my laptop was still plugged into it via USB—and in the blink of an eye, my laptop shut down completely!
It wouldn’t turn back on, not even a single sign of life, which was terrifying.
Almost everyone in the session tried to help and after many failed attempts, Mohanad was the one whose luck finally got it to turn back on at the very end of the session.
Alhamdulillah, my laptop survived, but the whole experience was shocking—and unfortunately, this was my first time not completing the offline session’s project.
Lesson learned: Always be extra cautious when connecting external power sources!
Very expressive, Isn't it? 😂