loading

The metropolitan in it's natural habitat; unaware, oblivious, purposefully deafened and subsequent prey. To increase perception thus safety, we wed an Arduino Nano and ultrasonic sensor to regulate volume to proximity to some one (thing) behind you; easily deactivated per environment (in-line slide switch) and rechargeable (3XCR2032). Beyond this proof of concept, intention for apparel or accessory (i.e. purse strap, back pack) embedding is ideal.

This prototype of a prototype is a mono-version. A stereo version would merely require dual channels (pots). Aptly, imagine if you will, you plug your head phones in to your purse strap which is embedded with a Metrophone with bluetooth that streams to your smart phone...or or or you could PAY ATTENTION! Sorry not sorry.

// MetroPhones
// TVMiller

#include 

// Chip Select Pin
int csp = 10;

// Sensor Values
long dur, dis;
// Echo Pin
int echo = 4;
// Trigger Pin
int trig = 5;

// Position
int pos = 0;

// Centimeters
// Minimum Distance
int mindis = 0;
// Maximum Distance
int maxdis = 90; // 2.6FT

void setup() {

  // Pot Com
  SPI.begin();
  pinMode(csp, OUTPUT);
  // Set Chip Select LOW
  digitalWrite(csp, LOW);

  // Testing
  Serial.begin (9600);

  // Sensor Pins
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);

}

void loop() {

  // Poll Sensor
  digitalWrite(trig, HIGH);
  delay(10);
  digitalWrite(trig, LOW);
  dur = pulseIn(echo, HIGH);
  // Convert to Centimeters
  dis = dur / 58.2;

  if (dis < maxdis) {
    // Convert Distance to Pot (256 Steps)
    pos = map(dis, mindis, maxdis, 0, 255);
    // Alert Chip
    SPI.transfer(0);
    // Adjust Volume
    SPI.transfer(pos);
  } else if (dis > maxdis) {
    pos = 255;
    SPI.transfer(0);
    SPI.transfer(pos);
  }

  // Testing
  Serial.print(dis);
  Serial.print("  ");
  Serial.println(pos);

  delay(100);
}

About This Instructable

97views

3favorites

License:

Bio: Privateer
More by TVMiller:Arduino Splash Resistant Toilet Foamer Arduino Motion Mute 1992 Isuzu Trooper Windshield Wiper Single Button Hack 
Add instructable to: