Birthday Surprise With Arduino


Introduction
-----------------
In a world where everything is new and interesting, surprises make your life awesome. It is a perfect way to add a spark to a dull week and make it fun. One way to give a smile on someone's face is by giving them a small gift. There is nothing like a gift that can bring a smile on someone's face and your own.
Electronics and love, are like the north-pole and the north pole, the only correlation between them is that they always repel each other. BUT, STEMpedia has given a new definition to love by combining love with electronics. By using this EVIVE STARTER KIT I am going to give a small surprise to my partner on her birthday.

Learn the basics of new-age tech, build countless projects, program robots, and become the innovator you’re destined to be!
@theSTEMpedia | #theSTEMpedia
- Facebook: https://www.facebook.com/theSTEMpedia/
- Instagram: https://www.instagram.com/theSTEMpedia/
- Twitter: https://twitter.com/theSTEMpedia
- Website: https://thestempedia.com

#Arduinoproject #birthdaysurprise

Circuit Diagram
----------------------

The plan is to shower love upon my partner with rose petals, as soon as she walks out of our bedroom.
For this project we need:
1. HC-SR04 Ultrasonic Sensor
2. SG90 Servo Motor
3. ATmega2560 powered evive Starter Kit
The good thing is, all these components are part of the evive Starter Kit.

Start by connecting the TRIG pin and the ECHO pin of the ultrasonic sensor to Pin numbers 12 and 11 of the Arduino.
Then connect the PWM pin of the servo to Pin number 9 of the Arduino.
After that we are going to connect all the +ve and -ve terminals of the sensors to the +ve and -ve pins of the Arduino.
That's it, it's just simple as that.

3D Model
-------------

Using a 3D model I am going to show you guys the design and working of the flower dispenser.
Alright, so this is the whole setup. The back bit sticks to the wall and using these two holders it holds a lightweight stick which in-turn will hold the front-bit or the dispenser. I am going to put all the rose petals in here. 
When the ultrasonic sensor detects an object in its way, it will send a signal to the Arduino, which will then rotate the servo causing the dispenser flap to open. When the flap opens all the rose petals will fall on my partner.
The whole setup is made using a cardboard box, making it lightweight and easy to stick to the wall.

Quick Demo
-----------------

So, this is how it looks like.
Once we power the evive starter kit, the ultrasonic sensor starts waiting for a moving object. As soon as an object is detected the flap opens up to dispense the flowers.

Code
-------
 

The code has two parts, in the first part we are detecting the motion using an ultrasonic sensor and in the second part, we are rotating the motor to open the flap whenever motion is detected.
Start by including the "Servo.h" library in the program. 
Then define the constants and the global variables that will be used throughout the code.
To use the servo we are creating an object of the Servo class. Then in the setup section, we are initializing the servo by using the "servo.attach()" function and defining the pin modes for the ultrasonic sensor.

Finally, in the loop() section after initializing the ultrasonic sensor we are checking if the distance of the moving object is less than 100cm. If the distance is less than 100cm we are going to open the flap by rotating the servo 90 degrees.

Inside the evive Starter Kit
-------------------------------------

  • The Evive Starter Kit contains:
  • The main Brain-Brick which is an Arduino Mega powered evive
  • 2 x Tires and Wheels
  • 2 x Drive Gear Motors
  • Some Cable-ties
  • Jumper Cables
  • 1 x USB cable
  • 1 x Screw Driver
  • 1 x 18650 Battery
  • 1 x Joystick
  • Few LDRs
  • Mechanical Parts For The evive Rover
  • Young Maker's Guide, which contains 18 chapters, 20+ projects and technical know-how
  • 2 x Servo Motors
  • 1 x Ultrasonic Sensor
  • 2 x IR Sensors
  • 1 x Bluetooth Module
  • Few LEDs
  • Few Pushbutton Switches
  • Crocodile Clips
  • Resistances...
Read more »