This combo containing all products needed to make a smart dustbin that opens automatically when someone comes near to the dustbin.
The Arduino Uno R3 Compatible Board is a microcontroller board that is based on the ATmega328. Arduino Uno has 14 digital input or output pins, 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It has everything needed to support the microcontroller, you need to simply connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to get started.
This HC-SR04-Ultrasonic Distance Measuring Sensor is a very popular sensor that is found in many applications where it requires measuring distance and detect objects. The HC-SR04 ultrasonic sensor uses sonar to determine the distance to an object like bats or dolphins do. The module has two eyes-like projects in the front which form the Ultrasonic transmitter and Receiver.
The Micro Servo 9G is lightweight, high-quality, and lightning-fast. The servo is designed to work with almost all radio control systems. It is with excellent performance that brings you to another horizon of flight.
This is the combo of 20CM Wire Color Jumper Cable, M-M, M-F, F-F 10PCS of wire in each strip of cable. It is very flexible and easily detachable to no. of wires to your requirement. Mostly it can be used for Orange Pi, Banana Pi, Raspberry Pi, Arduino, and other mini PC and development boards.
This is a general 9v Battery With Battery Snap Connector to DC barrel jack adapter for all your project and application needs. One can use this adapter to power up any DC barrel jack-based power connector using a standard 9V battery.
Package Includes:
1 x Arduino UNO R3 Compatible Board With Cable
1 x Ultrasonic Module HC-SR04 Distance Measuring Sensor
1 x Tower Pro 9G Micro Servo Motor
1 x HW Battery 9V With Barrel Jack Connector
1 x Combo of 3 type Jumper Cables | F-F | F-M | M-M
Code for the Smart Dustbin:
Do not forget to install Servo.h Library. without this library, code will not compile in Arduino IDE software.
For more details please check this article on Smart Dustbin.
#include //servo library
Servo servo;
int trigPin = 5;
int echoPin = 6;
int servoPin = 7;
int led= 10;
long duration, dist, average;
long aver[3]; //array for average
void setup() {
Serial.begin(9600);
servo.attach(servoPin);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
servo.write(0); //close cap on power on
delay(100);
servo.detach();
}
void measure() {
digitalWrite(10,HIGH);
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(15);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
dist = (duration/2) / 29.1; //obtain distance
}
void loop() {
for (int i=0;i<=2;i++) { //average distance
measure();
aver[i]=dist;
delay(10); //delay between measurements
}
dist=(aver[0]+aver[1]+aver[2])/3;
if ( dist<50 ) {
//Change distance as per your need
servo.attach(servoPin);
delay(1);
servo.write(0);
delay(3000);
servo.write(150);
delay(1000);
servo.detach();
}
Serial.print(dist);
}
There are no reviews yet.