Smart Dog Collar

My main project is the Smart Dog Collar. This is a dog collar with sensors on it that can sense things like speed, and when receiving a specific signal, cause the dog collar to vibrate.

Engineer

Anya

Area of Interest

School

Scarsdale High School

Grade

Incoming Sophomore

Final Milestone

Code

// these constants describe the pins. They won’t change:
const int xpin = A1; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A3; // z-axis (only on 3-axis models)
//
int sampleDelay = 500; //number of milliseconds between readings
int motorPin=5;
void setup()
{
// initialize the serial communications:
Serial.begin(9600);
//
//Make sure the analog-to-digital converter takes its reference voltage from
// the AREF pin
pinMode(xpin, INPUT);
pinMode(ypin, INPUT);
pinMode(zpin, INPUT);
pinMode(motorPin, OUTPUT);
}
void loop()
{
int x = analogRead(xpin);
//
//add a small delay between pin readings. I read that you should
//do this but haven’t tested the importance
delay(1);
//
int y = analogRead(ypin);
//
//add a small delay between pin readings. I read that you should
//do this but haven’t tested the importance
delay(1);
//
int z = analogRead(zpin);
//
//zero_G is the reading we expect from the sensor when it detects
//no acceleration. Subtract this value from the sensor reading to
//get a shifted sensor reading.
float zero_G =512;
//
//scale is the number of units we expect the sensor reading to
//change when the acceleration along an axis changes by 1G.
//Divide the shifted sensor reading by scale to get acceleration in Gs.
float scale =102.3;
//
//Serial.print(((float)x – zero_G)/scale);
Serial.println(x);
// Serial.print(“\t”);
// //
// //Serial.print(((float)y – zero_G)/scale);
// Serial.print(y);
// Serial.print(“\t”);
// //
// //Serial.print(((float)z – zero_G)/scale);
// Serial.print(z);
// Serial.print(“\n”);
// //
// delay before next reading:

// read the value of the accelerometer:
int motorValue = analogRead(motorPin);

// if the analog value is high enough, turn on the LED:
if (x > 400) {
digitalWrite(motorPin, HIGH);
} else {
digitalWrite(motorPin, LOW);
}

// print the analog value:
Serial.println(motorValue);
delay(1); // delay in between reads for stability
}

[/vc_column_inner]
I wrote the code for the accelerometer and the vibrating discs and I used an if, then conditional statement to make it so that, when the accelerometer senses a specific change in speed it triggers the vibrating disc to vibrate. I also attached a battery to the whole complex so that it can function without being connected to a computer. A challenge that I faced was figuring out how to make an if, then conditional statement so that the accelerometer could trigger the vibrating discs, but with some research I was able to figure it out. I also fried 3 of my Arduino nanos. For this part of this project, I liked uploading the code for the vibrating disc and accelerometer and it was very interesting to see how I could connect them with an if, then statement. When the accelerometer senses a change in the X coordinate over 500, it will signal the vibrating disk to vibrate.  I then put the whole complex onto the dog collar. For the whole project, the part that I liked was the actual assembly of the dog collar and the circuit, but the coding gave me the most difficulty. Bluestamp was a very fun experience, although it was hard at times, it really helped expand my knowledge of engineering.
[/vc_row_inner]

First Milestone

Build Plan

Name: Anya Pabby

Location: New York City

Instructor: Sebastian Roubert

Starter Project:  #11 Useless machine

Main Project: #115 Smart Dog Collar

 

Major Steps to complete the project:

  1. Make sure all parts have arrived as planned
  2. Draw a schematic that shows every wire that will need to be connected.
  3. Wire three vibrating discs and battery to the particle electron board- Milestone
  4. Make a pouch to hold board, discs, and battery (using sewing machine possibly).
  5. Write and test code that will make the dics vibrate- Milestone
  6. Attach pouch to the dog collar and test
  7. Create full documentation, write a blog post describing the system, and post everything on your webpage.- milestone

 

Potential Modifications:

  1. Wire sound sensor and/or speed sensor to arduino, write code for sensors and attach them to collar
Bill of Materials

Vibrating mini motor disc Adafruit 1201 3 $1.95
Lithium ion polymer battery- 3.7v 1200mAh Adafruit 258 1 $9.95
Dog Collar Amazon 27552 1 $8.78
LM393 Speed Measuring Sensor Photoelectric Infrared Count Sensor DC 5V Amazon STK0114017571 1 $2.75
Arduino Uno R3 Microcontroller A000066 Amazon A000066 1 $19.85
Sparkfun Sound Detector Sparkfun 12642 1 $10.95
For my first milestone, I soldered my Arduino to my accelerometer and I also soldered my vibrating disks to my Arduino. When I write the code for the accelerometer then I will be able to use it to sense increases in speed and when it does, it will signal the vibrating disk to vibrate. The accelerometer shows the X, Y and Z coordinates when there are changes in movement and speed.I used heat shrinks to make sure that the wires connecting the accelerometer to the Arduino board won’t become undone. Next, I have to write the code for both the accelerometer and the vibrating disc. During this part of the project, one of my challenges was uploading my code to my Arduino. I felt that the soldering and putting together the actual structure was easier than downloading the code.
Code For The Accelerometer

const int xpin = A1; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A3; // z-axis (only on 3-axis models)
//
int sampleDelay = 500;
void setup()
{

Serial.begin(9600);
//

pinMode(xpin, INPUT);
pinMode(ypin, INPUT);
pinMode(zpin, INPUT);
}
void loop()
{
int x = analogRead(xpin);
//

delay(1);
//
int y = analogRead(ypin);
//

delay(1);
//
int z = analogRead(zpin);
//

float zero_G =512;
//

float scale =102.3;
//
Serial.print(((float)x – zero_G)/scale);
Serial.print(“\t”);
//
Serial.print(((float)y – zero_G)/scale);
Serial.print(“\t”);
//
Serial.print(((float)z – zero_G)/scale);
Serial.print(“\n”);
//

delay(sampleDelay);
}

Arduino Board connected to the accelerometer

Starter Project

The name of this project is the useless machine. There are many different parts to this project some include, resistors, which are used to provide specific voltages and regulate the flow of electricity in a circuit. An LED- which provides the light when the top of the box opens. The light is activated by a battery pack connected to the motor by wires and a screw terminal. When the flip is switched the LED light lights up and the arm rotates counterclockwise due to the motor and the electrical current the motor receives from the battery pack connected to the PCB (printed circuit board) by wires. The PCB “connects electronic components using conductive tracks or pads.” The arm then comes out of the box, flips the switch back to the resting position and goes back into the box.  A challenge that I faced was that I had to restart the project. This is because, the first time, a circuit was fried and my batteries began to melt themselves. I overcame this by trying the project again and being extra careful of my soldering to make sure that there would be no more short circuits. I was way faster when I did the project a second time and was able to complete it in a day. This is because I had already done it once before so I knew what I was doing.

Leave a Comment

Start typing and press Enter to search