Apparatus required:
Connection/Working:
delay(10);
}
Visit for Instructables
For details follow us and ask in Contact Form. You will receive response in 24 hours
1x Ultrasonic sensor
1x Arduino Atmega328
1x Relay
1x fan
connecting wires As required
Connection/Working:
Step 1: Upload the program given below in to Arduino board
Step 2: Connect the Arduino and Ultrasonic sensor in to the pins trigPin-13, echoPin-12
Step 3: Connect relay to Arduino pin 2 and motor to relay
Step 3: Now click serial monitor in the Arduino software
Step 4: Move your sensor and find distance approx,
Step 5: Follow us and subscribe our YouTube channel
Program:
//Delay 10ms before next reading./*HC-SR04 based cooling fan distance sensor:VCC to arduino 5vGND to arduino GNDEcho to Arduino to pin 13Trig to Arduino pin 12*/#define echoPin 13 // Echo Pin#define trigPin 12 // Trigger Pin#define motor 2 // Relaylong duration, distance; // Duration used to calculate distancevoid setup() {pinMode(trigPin, OUTPUT);pinMode(echoPin, INPUT);pinMode(motor, OUTPUT); // cooling fan}void loop() {/* The following trigPin/echoPin cycle is used to determine thedistance of the nearest object by bouncing soundwaves off of it. */digitalWrite(trigPin, LOW);delayMicroseconds(2);digitalWrite(trigPin, HIGH);delayMicroseconds(10);digitalWrite(trigPin, LOW);duration = pulseIn(echoPin, HIGH);//Calculate the distance (in cm) based on the speed of fan.distance = duration/58.2;if (distance <= 50){digitalWrite(motor, HIGH);delay(50);}else {/* Send the distance to the computer using Serial protocol, andturn motor OFF to indicate successful reading. */digitalWrite(motor, LOW);delay(50);}
delay(10);
}
Visit for Instructables
For details follow us and ask in Contact Form. You will receive response in 24 hours
but in my Arduino it is saying me in correct
ReplyDelete