Rami AlramadhanJacob Brown
Published

The Key Box

A small key box that could help Alzheimer patients families to identify the location, and the time when the key box gets opened.

BeginnerFull instructions provided4
The Key Box

Things used in this project

Hardware components

Argon
Particle Argon
×2
Tracking Sensor
×1
Button Sensor
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
lucid.app

Story

Read more

Code

Tracking Sensor Code

C/C++
it is used to track the key box location
int tracking_sensor_pin =2;//sensor signal pin is connected to pin2.

void setup() {

  pinMode(tracking_sensor_pin , INPUT);//sensor signal pin declared as INPUT

  Serial.begin(9600);

}

void loop() {

  

  int TrackingSensor = digitalRead(tracking_sensor_pin);//reading Sensor signal pin

  if(TrackingSensor == 1){

   Serial.println("BLACK");

   delay(200);  

  }

  else if(TrackingSensor == 0){

   Serial.println("WHITE"); 

   delay(200);

  }

}

Button Code

C/C++
byte button =2;
unsigned long startTime;
unsigned long endTime;
unsigned long duration;
byte timerRunning;
void setup(){
pinMode (button, INPUT_PULLUP);
Serial.begin(9600);
}
void loop(){
  if (timerRunning == 0 && digitalRead(button) == LOW){ // button pressed & timer not running already
  startTime = millis();
  timerRunning = 1;
  }
  if (timerRunning == 1 && digitalRead(button) == HIGH){ // timer running, button released
  endTime = millis();
  timerRunning = 0;
  duration = endTime - startTime;
  Serial.print ("button press time in milliseconds: ");
  Serial.println (duration);
  }
}

Credits

Rami Alramadhan

Rami Alramadhan

0 projects • 1 follower
Jacob Brown

Jacob Brown

0 projects • 1 follower

Comments

Add projectSign up / Login