Project tutorial

Simple Door Prank with Arduino 1Sheeld © CERN-OHL

This tutorial shows how to make a simple door prank using an Arduino board and 1Sheeld.

  • 1,349 views
  • 0 comments
  • 7 respects

Components and supplies

Apps and online services

About this project

All you need to make this prank: Arduino board, Android phone, and an ultrasonic sensor.

The video below shows the final result:

Step 1: What You Need

Hardware:

  • Arduino Uno or Mega.
  • 1Sheeld
  • Ultrasonic sensor HC-SR04
  • Android phone (or iOS)
  • 3 x Connection wires
  • 1 x Breadboard

Software:

  • The Arduino IDE which you can download here
  • Get the 1Sheeld Arduino library and the phone app here

PS: Make sure to go through the 1Sheeld intro tutorial here and how to use 1Sheeld with different Arduino boards here. I will be using Arduino Mega for the rest of the tutorial.

Step 2: Wiring and Setup

Mount the 1Sheeld on the Arduino board. Make sure the power switch shown above is turned to 5V (for Arduino UNO users). If you're using another Arduino board, check here. Connect the ultrasonic sensor and the wires as shown in the figure.

Step 3: Software

Simply, the code opens the mp3 file that is selected from the Media Player Shield in the 1Sheeld app, and that happens only when any object is 25 cm or less in front of the ultrasonic sensor (you can change the distance as you like).

Upload the attached code and let's move to the next step.

Use your 1Sheeld mobile app (Media Player Shield) to get the signal from the ultrasonic sensor to open the mp3 file.

PS: Make sure the 1Sheeld is in upload mode as seen in the image above.

Step 4: Putting It All Together

After connecting all components as shown:

  • Connect the Arduino to your laptop and make sure the code is uploaded.
  • Switch the 1Sheeld back to operating mode.
  • Open your 1Sheeld app and connect your phone to your 1Sheeld board (check 1Sheeld tutorial here if you haven't already).
  • Select Media Player Shield, and press on the multiple shields icon at the top right of the app.

Now, put your circuit and your mobile phone in a hidden place and enjoy your prank.

Feel free to ask any questions in the comments and I'll answer them as best as I can.

Code

FEEIC39ITUQNVGL.inoArduino
/* Include 1Sheeld library. */
#include <OneSheeld.h>
#include <Ultrasonic.h>
#define CUSTOM_SETTINGS
#define INCLUDE_MUSIC_PLAYER_SHIELD
#define trigger_pin 12
#define echo_pin 11

long ultrasonic ()
  {
    long duration,distance;
  digitalWrite(trigger_pin,LOW);
delayMicroseconds(2);
digitalWrite(trigger_pin,HIGH);
delayMicroseconds(10);
digitalWrite(trigger_pin,LOW);
duration=pulseIn(echo_pin,HIGH);
distance=(duration/2)/29.1;
  delay(100);
  //Serial.println(distance);
  return distance;
    }

void setup() {
 Serial.begin(9600);
 
  /* Start communication. */
  OneSheeld.begin();
pinMode(trigger_pin, OUTPUT);
pinMode(echo_pin,INPUT);
}

void loop() {
if(ultrasonic()<=25){
       /* Set the volume. */
       MusicPlayer.setVolume(10);
       /* Turn on the music. */
       MusicPlayer.play();
       /* Wait for 3000 ms. */
       OneSheeld.delay(3000);
        /* Turn off the music. */
      MusicPlayer.pause();
      /* Wait for 1500 ms. */
      OneSheeld.delay(1500);
            }
}

Schematics

Schematic 1
Fsdow3ritum2uul large mmhbsfsu6z

Comments

Created by

Zowail

Are you Zowail? Claim this project and add it to your profile.

This is mine

Posted by

Ahmedismail
ahmed ismail
  • 5 projects
  • 74 followers

Additional contributors

  • Zowail

Published on

April 23, 2017

Members who respect this project

AhmedismailPhotoDefaultPhotoWannaduino

and 2 others

See similar projects
you might like

Similar projects you might like

Control Music Volume and Ledbar Using Slider of 1Sheeld

Project tutorial by ahmed ismail

  • 1,955 views
  • 2 comments
  • 14 respects

Home Automation using Arduino and 1Sheeld

Project tutorial by Ramy ElMallah

  • 4,347 views
  • 2 comments
  • 12 respects

Arduino can hear and understand your voice with 1Sheeld !

Project tutorial by Alessandro Didonna

  • 3,926 views
  • 1 comment
  • 10 respects

Arduino Based Amazon Echo Using 1Sheeld

Project tutorial by ahmed ismail

  • 42,127 views
  • 83 comments
  • 118 respects

4x4x4 LED cube with Arduino Uno and 1sheeld

Project tutorial by Hassan Ibrahim

  • 34,603 views
  • 7 comments
  • 64 respects

Arduino Digital Clock Using 1Sheeld

Project tutorial by amrmostaafaa

  • 2,329 views
  • 0 comments
  • 5 respects
Add projectSign up / Login