DIY Minority Report

Spoiler1: This is awesome.
Spoiler2: I’ve never seen Minority Report.

I do know that there is some sort of hands free interface, and that is what I have put together.

minority report

+1 dizzy

Long story short, I have extended upon my PING))) project to include some sweet touchless home automation. I have the ultrasonic sensor interfacing with my garage door and a lamp, utilizing a servo and a PowerSwitch Tail, respectively.

Hit the bump for an awesome video of this thing in action, and for my spippet.

*Video contains a rare thumbs up from the author*

Snippet? Oh, INDEED…

//DIY Minority Report

// Joseph Swanson | 2011

// Setup
// LEDs connected to pins 11, 2-5
// Ping))) sensor signal to pin 7
// Servo signal to pin 10
// PowerSwitch Tail to pin 13
// Ping))) +, servo + to 5V
// Ground the shit out of everything


Servo myservo;

int pos = 0;

// Pin assignment
const int ledPin1 = 11;
const int ledPin2 = 2;
const int ledPin3 = 3;
const int ledPin4 = 4;
const int ledPin5 = 5;
const int pingPin = 7;
const int lampPin = 13;

// Create variables to store LED states / lamp state
int ledState1 = LOW;
int ledState2 = LOW;
int ledState3 = LOW;
int ledState4 = LOW;
int ledState5 = LOW;
int lampState = LOW;
void setup() {

// Servo pin definition

//Define pins 1-5, lamp pin as output
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(lampPin, OUTPUT);
void loop()
// Reset LEDs levels to low to begin loop
ledState1 = LOW;
ledState2 = LOW;
ledState3 = LOW;
ledState4 = LOW;
ledState5 = LOW;
// Reset Servo position to initial location
pos = 0;

// Set duration variable
long duration, cm;

// Loop section for ping signal pin…start as output
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
digitalWrite(pingPin, HIGH);
digitalWrite(pingPin, LOW);

// Listen with same pin
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);

// Convert time to a distance
cm = microsecondsToCentimeters(duration);

// Configure this for LED sensitivity

// March through cm values…set levels where appropriate
if (cm < 95) { ledState1 = HIGH;} if (cm < 60) { ledState2 = HIGH;} if (cm < 40) { ledState3 = HIGH;} if (cm < 25) { ledState4 = HIGH;} if (cm < 10) { ledState5 = HIGH;} if (cm < 40 && cm >= 30 ) {
lampState = HIGH;}

if (cm < 25 && cm >= 15 ) {
lampState = LOW; }

if (cm < 10) { pos =( pos + 14 ); } // fire all LED lamp digitalWrite(ledPin1, ledState1); digitalWrite(ledPin2, ledState2); digitalWrite(ledPin3, ledState3); digitalWrite(ledPin4, ledState4); digitalWrite(ledPin5, ledState5); digitalWrite(lampPin, lampState); myservo.write(pos); delay(100); } long microsecondsToCentimeters(long microseconds) { // 340 meters per some math return microseconds / 29 / 2; }

As the code implies, I have set this thing up to look for pings in particular regions. The LEDs indicate where I am at, and the rest sort of plays out from there. The lamp is set up as a switch, with ON and OFF having separate regions. The servo/g-door opener is a simple ON when the region is occupied…similar to my previous setup.

Pretty flipping sweet. As usual, send any feedback my way. This is still in the proof-of-concept mode, and will likely get scrapped for parts soon. Not to mention, Katie will probably want to be able to use the garage door opener, which I disconnected to string that wire that I have running manually to the servo. Be prompt.

2 thoughts on “DIY Minority Report

  1. I’m not sure if I should tell you that you have way to much time on your hands….or if I should tell you that’s damn sweet…. I’m feeling festive so I’m gonna go with “That’s damn sweet”….very cool