Project showcase

LEDog Collar © GPL3+

The LEDog collar lights up when it gets dark, helping you locate your dog from far away.

  • 2,990 views
  • 2 comments
  • 17 respects

Components and supplies

About this project

Introduction

Welcome to another wearable project by circuito.io, this time for your doggy!

We have quite a few dogs running around here. You've met Luna, our office mascot, in the Evil Fruit bowl project and you've also met Yahoo in our Animatronic tail project (although he's not really ours).

And now you'll get to say Hi to Nikki!

LED Dog Night Collar

How does it work?

The night collar is a colorful and fun project you can make in no time.

The parts you need are: LDR - photo-resistive sensor, an LED Strip and an Arduino ProMini at its heart, powered by a Li-po 7.4v battery.

The basic functionality is simple: Once the sun sets the LDR triggers the LED strip that will play pre-coded sequences. As soon as the LDR detects light, it will finish the sequence and turn off the LEDs. So actually, it's an automatic LED collar that lights up when it gets dark, and you don't need to do a thing, except for charging the battery from time to time.

Setting up the circuit

Here’s a magic link to circuito.io which shows all the components you need for the project. You can add or remove different components from the circuit if you want.

If you would like to replicate the project we made exactly, click generate.

You can also make some adjustments to the circuit: for example you can add a Gyro sensor such as the MPU6050 and support it in the code so when your dog is sleeping or not moving, the LED display will stop and save power. You can also use a GPS and an SD module to monitor where your dog is wandering off to.

After clicking “Generate”, you’ll see 3 sections in the circuito.io Reply: BoM (Bill of materials), step-by-step wiring guide, and code.

  • Going through the BoM, make sure that you have all the parts you need. Notice that there are also auxiliary components such as capacitors and jumper cables, that are necessary for your project.
  • Next, follow the step-by-step wiring guide which will show you exactly how to put together your circuit.
  • Last, in the code section, you'll see a sample code for your circuit. This code is not specific for the tail project, but rather it is a sample code that activates the different components in your circuit.

To Upload the code, follow these steps:

  • Extract it to your computer
  • Open with Arduino IDE
  • Upload to your Arduino

Once everything works properly, replace the sample code you received from circuito.io with the code in this tutorial. Make sure to leave the //Include Libraries and //Pin Definitions at the top of the code, and also keep all the libraries that are on the original code from circuito.io.

Assembly

  • Get a collar that suits you and your dog.
  • Cut the LED strip to the desired length and attach it to the collar. Don't forget to change the number of pixels in the code according to the length you want.
  • 3D print the casing for the electronics, provided later in this tutorial.
  • Assemble the electronics in the casing.
  • Go have fun with your dog.

Custom parts and enclosures

Cover for electronics
Back of cover

Code

Code for LED CollarArduino
// Global variables and defines
#define THRESHOLD_ldr   100
int ldrAverageLight;
#define NUMOFPIXEL 27
// object initialization
LDR ldr(LDR_PIN_SIG);
Adafruit_NeoPixel ledStripBattery(LEDSTRIPBATTERY_PIN_DI);

// Setup 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);
  while (!Serial) ; // wait for serial port to connect. Needed for native USB
  Serial.println("start");

  ldrAverageLight = ldr.readAverage();
  ledStripBattery.begin(); // This initializes the NeoPixel library.
  ledStripBattery.show(); // Initialize all pixels to 'off'

}

// 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 current light reading, substract the ambient value to detect light changes
  int ldrSample = ldr.read();
  Serial.print(F("Light Diff: ")); Serial.println(ldrSample);
  if (ldrSample < 500)
  {
    rainbow(20);
    sequenceA();
    rainbowCycle(10);
    sequenceB();
    turnOff();

  }
}


void turnOff()
{
  for (int i = 0 ; i < NUMOFPIXEL ; i++) 
  {
    ledStripBattery.setPixelColor(i, ledStripBattery.Color(0, 0, 0)); // turn off last led
  }
  ledStripBattery.show(); //update pixel color to the hardware.
}


void sequenceA()
{
  for (int j = NUMOFPIXEL ; j > 0 ; j--)
  {
    for (int i = 0 ; i < j ; i++) 
    {
      // set pixels Color to RGB values, from 0,0,0 up to 255,255,255
      ledStripBattery.setPixelColor(i, Wheel(((i * 256 / NUMOFPIXEL) + j) & 255)); // turn on green color on led #i.
      if (i > 0)
        ledStripBattery.setPixelColor(i - 1, ledStripBattery.Color(0, 0, 0)); // turn off last led
      ledStripBattery.show(); //update pixel color to the hardware.
      delay(20);
    }
  }
}

void sequenceB()
{
  {
    for (int j = NUMOFPIXEL ; j > 0 ; j--)
    {
      for (int i = 0 ; i < NUMOFPIXEL ; i++)
      {
        for (int k = 0 ; k < 7 ; k++)
        {
          // set pixels Color to RGB values, from 0,0,0 up to 255,255,255
          ledStripBattery.setPixelColor((i + k) % NUMOFPIXEL , Wheel((((i + k) % NUMOFPIXEL * 256 / NUMOFPIXEL) + j) & 255)); // turn on green color on led #i.
          if (i > 0)
            ledStripBattery.setPixelColor(i - 1, ledStripBattery.Color(0, 0, 0)); // turn off last led
        }
        ledStripBattery.show(); //update pixel color to the hardware.

        delay(20);
      }
    }
  }
}



// =================== NeoPixel functions by Adafruit ====================//
//          https://github.com/adafruit/Adafruit_NeoPixel
// Fill the dots one after the other with a color
void rainbow(uint8_t wait) {
  uint16_t i, j;

  for (j = 0; j < 256; j++) {
    for (i = 0; i < ledStripBattery.numPixels(); i++) {
      ledStripBattery.setPixelColor(i, Wheel((i + j) & 255));
    }
    ledStripBattery.show();
    delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
    for (i = 0; i < NUMOFPIXEL; i++) {
      ledStripBattery.setPixelColor(i, Wheel(((i * 256 / NUMOFPIXEL) + j) & 255));
    }
    ledStripBattery.show();
    delay(wait);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return ledStripBattery.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if (WheelPos < 170) {
    WheelPos -= 85;
    return ledStripBattery.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return ledStripBattery.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

Comments

Similar projects you might like

Water Softener

Project tutorial by moty

  • 227 views
  • 0 comments
  • 5 respects

Simple Obstacle Senor With Arduino

Project tutorial by muhammed shameel k.v

  • 61 views
  • 0 comments
  • 2 respects

Know the Temp of Your Home From Anywhere with Arduino Cloud!

Project tutorial by Isaac100

  • 1,027 views
  • 0 comments
  • 9 respects

Safe City: A Device to Keep You Safe

Project tutorial by Patel Darshil

  • 560 views
  • 0 comments
  • 5 respects

Scavenger Hunt Clues w/ Telephone Keypad

Project tutorial by Sam Horne

  • 902 views
  • 0 comments
  • 3 respects
Add projectSign up / Login