Things used in this project

Hardware components:
A000066 iso both
Arduino UNO & Genuino UNO
×1
Hall effect sensor - A1302
×1
SparkFun Mini Speaker - PC Mount 12mm 2.048kHz
×1
SparkFun Graphic LCD 84x48 - Nokia 5110
×1
Software apps and online services:
8ztngd 9
circuito.io
Ide web
Arduino IDE

Custom parts and enclosures

Frame
Top
USB port

Code

Giftduino CodeArduino
copy and paste this code directly to the firmware tab in the code you downloaded from circuito.io
#include "Arduino.h"
#include "HallA1302.h"
#include "AnalogReader.h"
#include "Adafruit_GFX.h"
#include "Adafruit_PCD8544.h"
#include "TimerFreeTone.h"
#include "Speaker.h"


#define HALLA_PIN_VOUT	A3
#define NOKIALCD_PIN_DC	4
#define NOKIALCD_PIN_CS	2
#define NOKIALCD_PIN_RST	3
#define PIEZOSPEAKER_PIN_SIG	5

//define Nokia LCD contrast and dimentions(in pixels)
#define LCD_CONTRAST 70
#define LCD_SIZE_COL 84
#define LCD_SIZE_ROW 48

unsigned int piezoSpeakerHoorayLength          = 6;                                                      // amount of notes in melody
unsigned int piezoSpeakerHoorayMelody[]        = {NOTE_C4, NOTE_E4, NOTE_G4, NOTE_C5, NOTE_G4, NOTE_C5}; // list of notes. List length must match HoorayLength!
unsigned int piezoSpeakerHoorayNoteDurations[] = {8      , 8      , 8      , 4      , 8      , 4      }; // note durations; 4 = quarter note, 8 = eighth note, etc. List length must match HoorayLength!

HallA1302 hallA(HALLA_PIN_VOUT);
Adafruit_PCD8544 nokiaLcd(NOKIALCD_PIN_DC, NOKIALCD_PIN_CS, NOKIALCD_PIN_RST);
Speaker piezoSpeaker(PIEZOSPEAKER_PIN_SIG);




/* This code sets up the essentials for your circuit to work. It runs first every time your circuit is powered with electricity. */
void setup() {
  // Setup Serial which is useful for debugging
  // Use the Serial Monitor to view printed messages
  Serial.begin(9600);
  Serial.println("start");

  //Calibrate sensor
  //hallA.calibrate();
  //Initialize Nokia instance
  nokiaLcd.begin(LCD_SIZE_COL, LCD_SIZE_ROW);
  nokiaLcd.setContrast(LCD_CONTRAST); //Adjust display contrast
}

/* This code is the main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop. */
void loop() {
  //Get Measurment from hall sensor. Depending on the magnet pole polarity the sensor will return positive or negative values.
  int hallAVal = hallA.read();
  Serial.println(hallAVal);

  //Check if the box was opened
  if (abs(hallAVal - 512) < 50)
  {
    delay(500);//wait 0.5 sec
    nokiaLcd.clearDisplay();             //Erase & clear display buffer
    nokiaLcd.setRotation(2);
    nokiaLcd.setTextColor(BLACK);        //Set text color to black, background is white by default
    nokiaLcd.setTextSize(2);             //set text size
    nokiaLcd.setTextSize(1);             //set text size
    nokiaLcd.print("  Surprise !");
    nokiaLcd.setTextSize(2);             //set text size
    nokiaLcd.drawCircle(37, 15, 3, BLACK);
    nokiaLcd.drawCircle(41, 15, 3, BLACK);
    nokiaLcd.drawRect(25, 22, 30, 20, BLACK);
    nokiaLcd.drawRect(22, 18, 36, 5, BLACK);
    nokiaLcd.drawRect(37, 22, 5, 20, BLACK);
    nokiaLcd.display();                  //display on screen
    // The Speaker will play the Hooray tune
    piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
    delay(10000); //wait 10sec
  }

}

Credits

Jzbvk4go5lw68vtvbfe4
circuito.io team

Circuito.io is an online platform that generates wiring and code for Arduino projects. Want to know more? Visit http://circuito.io

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Voltmeter using Arduino
Easy
  • 537
  • 35

Protip

If you can't find voltmeter at home or at any other place, then this Hack is for you, Go ahead.

Voltmeter using Arduino

Team Next Tech Lab

Pranked! Moving Tissue Box | Circuito.io
Easy
  • 26
  • 3

Full instructions

When someone goes for a quick facial tissue, the box moves away from them unexpectedly!

PHPoC Sound-sensoring LED light control
Easy
  • 29
  • 4

Full instructions

Controlling LED light using a sound detecting sensor with PHPoC Blue

Hackster Live April 2017 Workshop - Optional - Easy Add-on
Easy
  • 140
  • 3

Full instructions

Adapt your home automation project from our March 2017 workshop to be controlled through BLE using the Blynk app on your phone.

Save your life with the Building Collapse Monitor
Easy
  • 245
  • 6

Full instructions

Analyse concrete, metal, wood structures for bends and angles and alerts if they have deviated from the original position.

Arduino 101 - Intel Curie Pattern Matching Dress
Easy
  • 2,466
  • 22

Full instructions

A dress with Curie's pattern matching engine on Arduino101 to control the embedded LEDs, which makes constellations show up on the dress.

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback