Van / Car RoofBox Proximity Alarm Project

in #arduino5 years ago (edited)

I recently added a roof box on to my "Micro Camper" for a camping trip, to store all the various things that obscure my rear windows when we are on the move such as bedding etc. However, Having never driven a 'tall' vehicle, I was concerned that I may end up driving into some height restricted carparks or entrances forgetting I had the roof box on. Normally these things are around 2 meters, and my car is now 2.4mtr.

I had a stack of old Minimus AVR 32k that I had lying around that I bought many many years ago from Leeds HackSpace, and didn't want to use an ESP8266 or Arduino for a permanent installation, as these Minimus were cheap.. Only a few GBP each. I found that that you could burn the arduino bootloader to them and use them pretty much like an Arduino, thanks to a repo by pbrook;

https://github.com/pbrook/minimus-arduino/wiki

So I used an 'Arduino as ISP' to burn the bootloader following his instructions, connecting up the MISO, MOSI, SCK, VCC and GND.. Firstly uploading the ISP sketch to the Arduino, and then selecting the board and burning the bootloader

Once this was done, the board can be used almost like an Arduino.

I had some of these ultrasonic waterproof surface mountable sensors, like that's used in parking sensors (From alibaba)

I connected up the ultrasonic sensor, and a piezo alarm buzzer (Beeps when supplied 5v)

/*
* Proximity Alarm
*
*/

const int buzzerPin = 0; 
const int trigPin = 9;
const int echoPin = 10;

long duration;
int distance;


void setup() {
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
pinMode(buzzerPin, OUTPUT);
digitalWrite(buzzerPin, LOW);

Serial.begin(9600);
}


void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);

delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;


Serial.print("Distance: ");
Serial.println(distance);

if(distance < 100) {
  digitalWrite(buzzerPin, HIGH);
  delay(1000);
}
else
{
  digitalWrite(buzzerPin, LOW);
}

}

So anything that comes within a meter of the top of the box, the alarm sounds.. Gives me enough time to hit the brakes!

I then boxed it up in an old printer cartridge box and drilled a hole for the sensor. Connected it all up, and it works!!

Sort:  

Congratulations @applicationist! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - A better rich list comparator
Vote for @Steemitboard as a witness to get one more award and increased upvotes!