Close
0%
0%

DumDum Detector

Arduino-based gag thing, when you point it at someone, it makes noise and flashes some LEDs.

Similar projects worth following
You can name it a lot of things. Dum dum detector, idiot identifier, stud sensor, fish finder, whatever. Using an ultrasonic range finder and an off-brand Arduino Nano, this dream becomes a reality... :P
Some really simple code thrown at some equally simple circutry to make what is technically a rangefinder. I log the process of the build, from blinky lights to LCD range display.

Why not. Almost totally useless, with no logical purpose, the DumDum Detector uses an HC-SR04 ultrasonic rangefinder module to trigger an Arduino Nano to produce escalating noises and blinky lights the nearer an object is to it. Originally designed for a display table to warn off those who come to near my precious bits (of tech), this project can annoy the whole family, or make at least one person you don't like feel bad.

Most of the initial fiddling was done without the good sense of some noise limiting device. This caused my popularity rating in the house standings to plummet. Later on I added a pot to tone it down.

Being a total Arduino noob, I patched together bits of example code with a bit of code from Circuit Basics http://www.circuitbasics.com/how-to-set-up-an-ultrasonic-range-finder-on-an-arduino/ and flavoured to suit my sadism. I will include my code, but beware, it's a little bit Frankenstein and progressive (older code will appear where it is chronologically appropriate).

RangeLedFrqBeep.ino

Not sure if this is the final one, because there was no final sketch; I just kept flogging it....

ino - 944.00 bytes - 01/22/2017 at 04:18

Download

  • 1 × Arduino Nano
  • 1 × HC-SR04 Ultrasonic Rangefinder
  • 4 × 220 ohm resistors
  • 3 × LEDs; Red, Yellow, Green I thinK these were 12V 3mm
  • 1 × 8 ohm Laptop speaker tried a few different ones, anything 8 ohm worked, but sound quality was diff

View all 8 components

  • You know what this needs? LASERS!!

    ken.do03/07/2017 at 15:02 0 comments

    I decided that, although cool, there was something lacking. I just got a whack of little laser diodes in da mail, so it was just a matter of time before everything had lasers attached; arduino projects, flashlights, the baby... (I cannot condone the use of lasers on small humans, in fact all my children are too big to accessorize in that fashion)

    Adding a laser seems like big medicine, however in actuality, it is super easy. All I needed was power and a switch (cause ya don't want it to be on all the time). The units I got were rated at 5V. Easy peasey cause I already gots 5V coming off the arduino. A tactile momentary switch and BOOM, thar she be.

    Photos to follow...

  • Ok... Time to really geek it up.

    ken.do01/24/2017 at 01:00 0 comments

    Want to know exactly how far away a DumDum is? I took the next step and wired in a 16 x 2 LCD that displays the distance in cm. It took a while to figure out the wiring for the LCD, but here it is. And the appropriate code too.

    Code:

    #include <LiquidCrystal.h>
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    
    
    int ledRed = 9;
    int ledGre = 6;
    int ledYel = 7;
    
    
    
    
    #define trigPin 10
    #define echoPin 13
    
    
    
    
    void setup() {
    
    
      pinMode(trigPin, OUTPUT);
      pinMode(echoPin, INPUT);
      pinMode(ledRed, OUTPUT);
      pinMode(ledYel, OUTPUT);
      pinMode(ledGre, OUTPUT);
      lcd.begin(16, 2);
    }
    
    
    void loop() {
      float duration, distance;
      digitalWrite(trigPin, LOW); 
      delayMicroseconds(2);
     
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
      
      duration = pulseIn(echoPin, HIGH);
      distance = (duration / 2) * 0.0344;
    
    
      lcd.clear();
      lcd.print("Distance = ");
      lcd.print(distance);
      lcd.print(" cm");
      delay(100);
      
      
      if (distance <=400) {
        tone(8, ((150 - distance) * 10));
      }
      else {
        tone(8, 0);
        analogWrite(ledGre, LOW);
        analogWrite(ledYel, LOW);
        analogWrite(ledRed, LOW);
      }
      if (distance >= 60 && distance < 200){
        analogWrite(ledGre, 350);
        
      }
      else {
        analogWrite(ledGre, LOW);
      }
      
     if (distance > 30 && distance < 60){
        analogWrite(ledYel, 600);
       
      }
      else {
          analogWrite(ledYel, LOW);
     }
    
    
      if (distance <= 30){
        analogWrite(ledRed, 350);
     
      }
        else {
        analogWrite(ledRed, LOW);
    }
      
      delay(distance * 3);
    }
    
    Hardwares:

    Just a note: That resistor is a 220k and the potentiometer is a 10K...

    *Please note: These fritzing diagrams are intended to show only the proper connections, not necessarily the proper routing of components and wires... Bear this in mind if you are trying to replicate this build.*

  • Next comes sound...

    ken.do01/24/2017 at 00:35 0 comments

    I played around a bit with static tones found in the 'pitches.h' library, with a different tone being played for each range step (ie. when the led changed). Kinda cool, kinda boring...

    So I decide to spice it up and made the pitch vary as a function of the distance. Much more rewarding. Much more annoying... The closer you are, the high it screams.

    Taking it another step into sonic oblivion, I made the delay an inverse function of distance. Now the closer you get, the higher it screams, AND it screams more often. Wow.

    Code:

    int ledRed = 9;
    int ledGre = 6;
    int ledYel = 7;
    
    #define trigPin 10
    #define echoPin 13
    
    void setup() {
    
      pinMode(trigPin, OUTPUT);
      pinMode(echoPin, INPUT);
      pinMode(ledRed, OUTPUT);
      pinMode(ledYel, OUTPUT);
      pinMode(ledGre, OUTPUT);
    }
    
    void loop() {
      float duration, distance;
      digitalWrite(trigPin, LOW); 
      delayMicroseconds(2);
     
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
      
      duration = pulseIn(echoPin, HIGH);
      distance = (duration / 2) * 0.0344;
      
      if (distance <=400) {
        tone(8, ((150 - distance) * 10));
      }
      else {
        tone(8, 0);
        analogWrite(ledGre, LOW);
        analogWrite(ledYel, LOW);
        analogWrite(ledRed, LOW);
      }
      if (distance >= 90 && distance < 200){
        analogWrite(ledGre, 350);
        
      }
      else {
        analogWrite(ledGre, LOW);
      }
      
     if (distance > 50 && distance < 90){
        analogWrite(ledYel, 600);
       
      }
      else {
          analogWrite(ledYel, LOW);
     }
    
    
      if (distance <= 50){
        analogWrite(ledRed, 350);
     
      }
        else {
        analogWrite(ledRed, LOW);
    }
      
      delay(distance * 3);
    }

    Hardwares:

    By default, pin D8 is audio out. I ended up throwing a pot in the positive line to limit the volume...

    *Please note: These fritzing diagrams are intended to show only the proper connections, not necessarily the proper routing of components and wires... Bear this in mind if you are trying to replicate this build.*

  • Then there was light...

    ken.do01/22/2017 at 07:02 0 comments

    To start my journey into this half-day project, I downloaded the Arduino programming tools and headed over to Adafruit to check out their tutorials. I found the infamous "Blink" program in the Example code and flashed it onto the Nano, and what do you know.... it blinked.

    Went a little farther, using Adafruit tutorials as a hardware guide and example code included in the Arduino tools to make an 'external' LED fade. (See Fade example in Arduino Examples code)

    Then I found this Circuit Basics tutorial on setting up the rangefinder. Everything worked great. Almost. One glitch, but it was my bad.

    I thought, 'Hmmm... what can I do to make this a little more fun?' So I came up with the idea of indicator LEDs to show how far away something was.

    Code:

    int ledRed = 9;
    int ledGre = 6;
    int ledYel = 7;
    
    #define trigPin 10
    #define echoPin 13
    
    void setup() {
    
      pinMode(trigPin, OUTPUT);
      pinMode(echoPin, INPUT);
      pinMode(ledRed, OUTPUT);
      pinMode(ledYel, OUTPUT);
      pinMode(ledGre, OUTPUT);
    }
    
    void loop() {
      float duration, distance;
      digitalWrite(trigPin, LOW); 
      delayMicroseconds(2);
     
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
      
      duration = pulseIn(echoPin, HIGH);
      distance = (duration / 2) * 0.0344;
      
      if (distance >= 50){
        analogWrite(ledGre, HIGH);
      }
      else {
        analogWrite(ledGre, LOW);
      }
      
     if (distance > 20 && distance < 50){
        analogWrite(ledYel, HIGH);
      }
        else {
          analogWrite(ledYel, LOW);
     }
    
      if (distance <= 20){
        analogWrite(ledRed, HIGH);
      }
        else {
        analogWrite(ledRed, LOW);
    }
      
      delay(500);
    }
    

    Hardwares:

    The LEDs glow a bit weak, but it works...

    Here is the hookups for the rangefinder only...

    *Please note: These fritzing diagrams are intended to show only the proper connections, not necessarily the proper routing of components and wires... Bear this in mind if you are trying to replicate this build.*

View all 4 project logs

Enjoy this project?

Share

Discussions

ken.do wrote 01/24/2017 at 20:44 point

Thanks! It's 20% more annoyinger in person.

  Are you sure? yes | no

David H Haffner Sr wrote 01/24/2017 at 07:12 point

I had to like this project just for the fabulous annoyance factor!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates