Noah CowenLandin Mills
Published © GPL3+

Accountability Boxes

This product allows for accountability with a partner. If the box is opened without the password an alarm sounds and notifies the partner.

IntermediateFull instructions providedOver 1 day10
Accountability Boxes

Things used in this project

Hardware components

Argon
Particle Argon
×2
Reed Switch, SPST-NO
Reed Switch, SPST-NO
×1
Elegoo 4X4 Membrane Switch
×1
Elegoo Active Buzzer
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Maker service
IFTTT Maker service
Google Sheets
Google Sheets
Fritzing

Hand tools and fabrication machines

Drill / Driver, Cordless
Drill / Driver, Cordless
Files

Story

Read more

Custom parts and enclosures

Can Enclosure

Enclosure for the can and circuit.

Lid for Can Enclosure

Lid for the Can Enclosure

Keypad Enclosure

Enclosure for the keypad and its circuit

Lid for Keypad Enclosure

Lid for the Keypad Enclosure

Schematics

Accountability Box Diagram

This is the diagram for the box itself using a Particle Argon and a reed switch.

Keypad Circuit Diagram

This shows the keypad circuit which uses the keypad, a buzzer, and the Particle Argon.

Code

Keypad Code

C/C++
This code is used to program the argon that goes into the keypad box. The argon will read when a user inputs the proper code and will notify the lockbox device.
// This #include statement was automatically added by the Particle IDE.
#include <Keypad_Particle.h>

int speakerPin = D8; 
int invalidcount=12;
int currentposition=0;



int accessgranted = 0;

char* password="22B8";

const byte rows=4;
const byte cols=4;
 
char key[rows][cols]={
{'1','2','3', 'A'},
{'4','5','6', 'B'},
{'7','8','9', 'C'},
{'*','0','#', 'D'}
};

byte rowPins[rows]={D7, D6, D5, D4};
byte colPins[cols]={D3, D9, D1, D0};

Keypad keypad= Keypad(makeKeymap(key),rowPins,colPins,rows,cols);

 
void setup()
{
pinMode(A5, INPUT);
pinMode(A4, INPUT);
pinMode(A3, INPUT);
pinMode(D9, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(D8, OUTPUT);
pinMode(D10, OUTPUT);
pinMode(D11, OUTPUT);
pinMode(D12, OUTPUT);
pinMode(D13, INPUT_PULLUP);

  Particle.subscribe("RESPONSE", myHandler, MY_DEVICES);

pinMode(speakerPin, OUTPUT);
Serial.begin(9600);
}
 
void loop()
{
   
    accessgranted = 0;

    char code=keypad.getKey();
    if(code!=NO_KEY)
    {

        for(int l=0; l<=currentposition; l++)
        {
        }
        if (code==password[currentposition])
        {
            tone(speakerPin, 3000, 25);
            delay(50);
            noTone(speakerPin);
            ++currentposition;
            if(currentposition == 4)
            {
                unlockdoor();
                currentposition=0;
                
                
                
                
 
            }
 
        }
        else if (code!=password[currentposition] && code == password[0])
        {
            tone(speakerPin, 3000, 25);
            delay(50);
            noTone(speakerPin);
            currentposition = 1;
        }
        else
        {
            ++invalidcount;
            incorrect();
            currentposition=0;
            Particle.publish("CODE", "INCORRECT", PRIVATE);
 
        }
    }
     
   
    
    
}

//********OPEN THE DOOR FUNCTION!!!!***********//
 
void unlockdoor()
{
   
   // unlockbuzz();
    Particle.publish("CODE", "CORRECT" , PRIVATE);
   // accessgranted = 1;
    delay(500);
    ///countdownbuzz();
    
    currentposition = 0;
   // accessgranted = 0;
}
 
//************WRONG CODE FUNCTION********//
 
void incorrect()
{
    tone(speakerPin, 3000, 25);
    delay(50);
    noTone(speakerPin);
}

//**************KEYPRESS********************//
/*void keypress()
{
 
 

tone(speakerPin, 3000, 25);
delay(50);
noTone(speakerPin);
}*/
//**********UNLOCK BUZZ*************//
void unlockbuzz()
{
 
tone(speakerPin, 3000, 25);
delay(80);
noTone(speakerPin);
delay(80);
tone(speakerPin, 3000, 25);
delay(200);
noTone(speakerPin);
delay(80);
tone(speakerPin, 3000, 25);
delay(80);
noTone(speakerPin);
delay(80);
tone(speakerPin, 3000, 25);
delay(80);
noTone(speakerPin);
delay(80);
}


//**********INVALID ACCESS*************//
void invalidbuzz ()
{
    tone(speakerPin, 3000, 25);
    delay(75);
    tone(speakerPin, 3000, 25);
    delay(50);
    
   /* tone(speakerPin, 3000, 25);
    delay(500);
    tone(speakerPin, 3000, 25);
    delay(500);
    tone(speakerPin, 3000, 25);
    delay(500);
    */
}

//**********Countdown Buzz*************//
void countdownbuzz ()
 { 
    for (int u = 0; u < 5; u++) 
    {
        tone(speakerPin, 3000, 25);
        delay(990);
        noTone(speakerPin);
        delay(10);  
    }
    
    for (int i = 0; i < 10; i++) 
    {
        tone(speakerPin, 3000, 25);
        delay(490);
        noTone(speakerPin);
        delay(10);  
    }
    
    for (int l = 0; l < 10; l++) 
    {
        tone(speakerPin, 3000, 25);
        delay(240);
        noTone(speakerPin);
        delay(10);  
    }
    
    for (int j = 0; j < 10; j++) 
    {
        tone(speakerPin, 3000, 25);
        delay(115);
        noTone(speakerPin);
        delay(10);  
    }
    
    for (int k = 0; k < 20; k++) 
    {
        tone(speakerPin, 3000, 25);
        delay(52.5);
        noTone(speakerPin);
        delay(10);  
    }
    
    tone(speakerPin, 4000, 25);
    delay(1000);
    noTone(speakerPin);
}

void myHandler(const char *event, const char *data)
{
     if (strcmp(data,"INVALID")==0){
       invalidbuzz();
        }
        
    else if (strcmp(data,"VALID")==0){
       countdownbuzz();
        Particle.publish("CODE", "TIMESUP" , PRIVATE);
        }
}
 

Lockbox Code

C/C++
This code is used to program the Argon that is inside of the lockbox. This device will look for a change in the Reed switch value and report it back to the keypad box.
int reed_switch = D13;
int val = 0;
int accessgranted = 0;
int red_light_pin = D10;
int green_light_pin = D11;
int blue_light_pin = D12;

void setup() {
pinMode(reed_switch, INPUT_PULLUP);
pinMode(D10, OUTPUT);
pinMode(D11, OUTPUT);
pinMode(D12, OUTPUT);

Particle.subscribe("CODE", myHandler, MY_DEVICES);
}



void myHandler(const char *event, const char *data)
{
if (strcmp(data,"CORRECT")==0){
        accessgranted = 1;

 }
 if (strcmp(data,"TIMESUP")==0){
        accessgranted = 0;


  
   
    accessgranted = 0;
 }
 
}
void RGB_color(int red_light_value, int green_light_value, int blue_light_value)
{
digitalWrite(red_light_pin, red_light_value);
digitalWrite(green_light_pin, green_light_value);
digitalWrite(blue_light_pin, blue_light_value);
}

void loop() {

val = digitalRead(reed_switch);

if (val == HIGH && accessgranted == 0)
    {
       RGB_color(255,0,0);
       delay(50);
       RGB_color(0,0,0);
        Particle.publish("RESPONSE", "INVALID", PRIVATE);
        delay(1000);
        
    }
    else if (val == HIGH && accessgranted == 1)
    {
        RGB_color(0,255,255);
        delay(50);
        RGB_color(0,0,0);
        Particle.publish("RESPONSE", "VALID", PRIVATE);
        delay(20000);
       
    }

}

Credits

Noah Cowen

Noah Cowen

1 project • 1 follower
Landin Mills

Landin Mills

0 projects • 1 follower

Comments

Add projectSign up / Login