Introduction: The Disruption Application

Picture of The Disruption Application

Parts needed:

Arduino Arduino board USB connector Sensor: Ultrasonic Sensor Male to female Jumper cables Motor: vibration (coin) motor Male to male Jumper cables 2N2222 NPN Transistor 1K ohm resistor Breadboard

Step 1: ​Sensor

Picture of ​Sensor

The first thing you need is to make sure the sensor is working. Attach the female ends of the jumper cables to the Ultrasonic sensor’s 4 ports and the male ends to the Arduino.

Vcc is power so using a red or warm colored jumper is recommended(male end goes to 5v on Arduino)

GND is ground so using a black or cool colored jumper is recommended(male end goes to GND on Arduino)

Trig and Echo can be any two colors. Male connected to Trig goes to Digital 12 on Arduino(see code). Male connected to Echo goes to Digital 13 on Arduino(see code)

Now import code into Arduino board. The sensor should work without the motor during testing.

Step 2: Motor

Picture of Motor

The motor is slightly more complex. There will be three male to male wires to connect to the arduino. But only two connect to the motor.

Use two jumpers to connect the motor’s Ground and Power and attach them to the breadboard. The Power cable can go straight to the 3.3v port on the Arduino(or connect to another jumper to go to port). However, the Ground cable must connect to the “C” end of the Transistor. Attach a cool-colored jumper to the “E” end of the Transistor then connect to GND on the Arduino. Finally, attach the resistor to the “B” end of the Transistor, attach a jumper to the resistor, and connect to Digital 3 on the Arduino(see code).

The motor should work with the code and sensor.

Step 3: Additional Steps for Application:

Picture of Additional Steps for Application:

You will need a way to attach the motor to your device(preferably a working drawbot but in this instance we’ll use a sharpie). I had to use non conductive wire and tape to be able to hold the motor to a sharpie, but you can probably find a better way to attach the motor to your device.

The reason I call this an application is because I don’t believe this to be a complete robot but a tool to apply to other robots(or draw bots).
The idea is that a draw bot would try and make a perfect pre programed drawing(such as a straight line or a circle.) But if the Disruptor's sensor is set of by someone being too close, the motor shakes and the drawing is changed drastically. So I’m posting this online for anyone that might be interested in doing a project like that.

Step 4: Code (Have Fun!)

/*

HC-SR04 Ping distance sensor VCC to Arduino 5V GND to Arduino GND Echo to Arduino pin 13 Trig to Arduino pin 12 Motor to Arduino pin 3 Original code improvements to the Ping sketch sourced from Trollmaker.com Some code and wiring inspired by http://en.wikiversity.org/wiki/User:Dstaub/robotcar Modified by Tolson Winters (Aug 27, 2014) for simplified serial monitor reading. Modified by Anthony Pease (Nov 9, 2015) for motor interaction */

#define trigPin 12 #define echoPin 13 #define moterPin 3

const int motorPin = 3;

void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(motorPin, OUTPUT);

}

void loop() { long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/2) / 29.1;

Serial.print("In Range: "); Serial.print(distance); Serial.println(" cm");

if (distance <= 45 && distance >= 2){ Serial.print("Active "); digitalWrite(motorPin, HIGH); delay(100); } else { digitalWrite(motorPin, LOW); delay(100); } delay(100); }

Comments

tomatoskins (author)2015-11-09

I love arduino! Thanks for sharing your project!