SMARTHOME
Hello guys, this time we will discuss about the application of HCSR04 in the application of SMARTHOME at home. Before continuing to make, it would be nice to recognize the important components that we use, among others HC-SR04 and Arduino, for more details see the explanation below.
WHAT IS ARDUINO?
Arduino is an open-source single-board micro controller, derived from the Wiring platform, designed to facilitate the use of electronics in various fields. The hardware has the Atmel AVR processor and the software has its own programming language. Arduino is currently very popular throughout the world. Many beginners learn to know robotics and electronics through Arduino because they are easy to learn. But not only beginners, hobbyists or professionals also enjoy developing electronic applications using Arduino. The language used in Arduino is not a relatively difficult assembler, but C language is simplified with the help of Arduino libraries. Arduino software itself is Arduino IDE, which can be installed on your PC or Laptop.
WHAT IS HC-SR04?
Trig = Trigger This pin is used to generate ultrasonic signals.
Echo = Receive / Indicator. This pin is used to detect ultrasonic reflection signals.
Ingredients in making Smarthome
1. Arduino Uno R3
2. HC-SR04
3. Mini Servo
4. Pen
5. Male to Male jumper cable
6. Male to Female jumper cable
7. Adapters
8. Project Board
9. Rope
10. Trash can
Make a Step
1. Prepare the ingredients needed
Prepare materials used as Electronic Circuits to support your Smart Home work such as, Arduino + Usb Cables, Projectboard, HC-SR04, Mini Servo, Jumper Cables, Pens and Trash.
2. Components are arranged as shown
The next step is to assemble the components, as shown above:
1. Add glue to the Arduino and Project Board, then paste it into the Trash as shown above.
2. Then connect Pin 5V and Gnd on Arduino with the Project Board (5V Arduino to (+) Project Board) and (Gnd Arduino to (-) Project Board).
3. Connect the Orange Cable in the Servo with Pin 8 in Arduino.
4. Connect the Red Cable on the Servo with (+) on the Project Board, and the Brown Cable on the Servo with (-) on the Project Board.
5. Connect the VCC on HC-SR04 with the Project Board (+).
6. Connect the Gnd to HC-SR04 with the (-) Project Board.
7. Connect the Trig pin on HC-SR04 with Arduino Pin 12.
8. Connect the Echo pin to HC-SR04 with Arduino Pin 11.
9. Then add glue to HC-SR04 and stick it right in front of the Trash to detect the presence of people
10. Attach also to the pen, and attach it directly to the top or close the trash can.
11. Insert the string inside the pen, then close it and connect it with the servo lever by attaching it.
12. Also servo glue and make sure the trash bin is slightly open, then aim the lever 90 °.
13. Connect the USB cable to Arduino with your laptop, and enter the program below.
14. You can adjust the angle of the trash can by adjusting servo.write ().
15. You can set your own time to open the trash can by setting a delay ().
16. You can also adjust the sensor detection distance yourself so that the trash can is open by adjusting if (distance <...)
PROGRAM CODE
#include <Servo.h>
Servo servo;
int angle = 10;
// defines pins numbers
const int trigPin = 12;
const int echoPin = 11;
// defines variables
long duration;
int distance;
void setup() {
servo.attach(8);
servo.write(angle);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}
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;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
delay(10);
if(distance<100)
{
servo.write(180);
delay(4000);
}
else
{
servo.write(0);
}
}
Reference references that support:
https://zona-teknikk001.blogspot.com/2020/06/make-smart-home-using-voice-commands.html
https://www.andalanelektro.id/2018/09/cara-kerja-dan-karakteristik-sensor-ultrasonic-hcsr04.html
0 Response to "Making Smart Trash Cans is Simple - Complete with the methods"
Post a Comment