Updated specific locations to be searchable, take a look at Las Vegas as an example.

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
Face off: Arduino vs Car.
Post Body

(Sorry if this double posts, I am having difficulty with my posts)

First, thanks very much for the help and comments I received in my original post about an automatic garage exhaust fan in another subreddit. Between that and additional projects I looked, at I have built a solution.

Behavior: When my car enters the garage it comes into a range that kicks off the fan for a specified period of time. So long as the car remains in the determined range, the cycle will not run again.

Hardware: Arduino, hypersonic sensor, 5v relay and some indicator LEDs

Photos at end of post...

What I am asking for...

This works great, however, as the car exits the garage, the fan is cycled again. I would like to not have this occur. IE: the fan only cycles when the car returns to the garage. This would allow me to add some additional "on arrival" behaviors I do not want to occur on departure such as delayed closure of the garage door.

FYI - though the project sits next to a double-gang outlet box, only one half is affected by the Arduino. The other pair provides power to the Arduino. The 5v relay enables a switched outlet so that I can override and disable the outlet if I wish, such as when working in the garage and frequently walking into range.

Thank you for your help. I am new and learning and very interested in understanding more.

Side Note: I did notice today the fan on later after I parked. I am not sure if the sensor is getting false readings (when looking at the serial output, things seem normal) or if the Arduino hangs and the relay remains open. OR maybe it is because I left, the fan kicked on, and I returned prior to the end of the cycle. Curious if there's a gap in my logic.

Code:

//***** The goal is to be able to use the ultrasonic timer to detect the presence of a parked car

//When sensed, the 5v relay and an LED are enabled

//When enabled, the relay and LED run for a set time and then turn off

//So long as the car remains, the fan will not start again

//******

int trigPin = 11; // ultrasonic sensor's trig pin connected to 11

int echoPin = 12; // ultrasonic sensor's echo pin connected to pin 12

int relayPin = 10; // relay connected to pin 10

int ledPin = 13; // lights up while relay is powered (pin 10)

long duration; // time between sending and recieving the sound

void setup (){

//Serial Port begin

Serial.begin (9600);

//initial pin modes

pinMode (echoPin, INPUT); // sets pin as input

pinMode (trigPin, OUTPUT); // sets pin as output

pinMode (relayPin, OUTPUT); // sets pin as output

pinMode (ledPin, OUTPUT); // lights when fan relay is powered

digitalWrite (relayPin, LOW); // sets 5v out put to relay to off

pinMode (8, OUTPUT); // indicates power

digitalWrite (8, HIGH); // lights LED

}

void loop (){

long duration, distance;

// digitalWrite(trigPin, LOW); // seems redundant?

digitalWrite(trigPin, HIGH);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

//so long as the object enters this range and remains within it, the LED and Relay will only cycle once

if (distance < 180 and distance > 100) { // between ~5' and ~3' is where the LED and Relay fire up

digitalWrite(ledPin,HIGH); // LED comes on to indicate power

digitalWrite(relayPin,LOW);// Relay comes on and enables outlet

delay(900*1000); // 15 min timer for LED and Relay.

}

//any other condition, disable LED and Relay

else {

digitalWrite(relayPin,HIGH);

digitalWrite(ledPin,LOW);

//serial print to PC during testing

Serial.print("Distance: ");

Serial.print(distance);

Serial.println(" cm");

}

delay(500);

}

Green for power, red when activated.

Arduino Vs Classic

Author
Account Strength
70%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
4,938
Link Karma
1,529
Comment Karma
3,344
Profile updated: 4 days ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago