0% found this document useful (0 votes)
2 views17 pages

Smart-Dustbin Module

The document outlines the setup and coding for a Smart-Dustbin project using Arduino, detailing the circuit connections for an ultrasonic sensor and a servo motor. It explains the code structure, including variable declarations, setup functions, and the main loop for measuring distance and controlling the dustbin lid. The project utilizes object-oriented programming principles and emphasizes the importance of debugging through serial communication.

Uploaded by

mredward eu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views17 pages

Smart-Dustbin Module

The document outlines the setup and coding for a Smart-Dustbin project using Arduino, detailing the circuit connections for an ultrasonic sensor and a servo motor. It explains the code structure, including variable declarations, setup functions, and the main loop for measuring distance and controlling the dustbin lid. The project utilizes object-oriented programming principles and emphasizes the importance of debugging through serial communication.

Uploaded by

mredward eu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Smart-Dustbin

using Arduino
Circuit Board

Connect signals to
sensors / digital pins

Digital Input / Output

Read analog
sensor
Wire Connection
Ultra-sonic Sensor:
VCC to 5V
GND to GND
Trig to Pin 5
Echo to Pin 6
Servo Motor:
VCC to 5V
GND to GND
Signal to Pin 7
Code Explaination
Introduction

Object-Oriented Programming language

contains library, and


predefined functions

function starts and end with ‘ {} ‘ each line ends with ‘ ; ’


Introduction

Data type (int, str, dbl, bool)

variable = space to stores one data


Introduction
Function = a set of instructions to execute a specific task
Let’s Start
Variable Declaration

servo: Declares a Servo object.


trigPin and echoPin: Pins used for ultrasonic sensor connections.
servoPin: Pin connected to the servo motor.
minDistance: Minimum distance at which the lid should open (adjustable).
Setup Function

Serial.begin(9600): Initializes serial communication at a baud rate of 9600.


servo.attach(servoPin): Attaches the servo to the designated pin.
Configures trigPin as an output and echoPin as an input.
Sets the servo to a closed position and then detaches it.
Measure Distance Function

This function calculates the distance measured by


the ultrasonic sensor.
It sends a short pulse to the sensor, measures the
duration of the echo, and calculates the distance
based on the speed of sound.
Open Cap Function

This function opens the dustbin's cap by rotating the servo motor.
It attaches the servo, sets the angle to open the cap, waits for a
moment, then closes the cap slightly.
Loop Function
This function continuously
loops.
It takes multiple distance
readings, averages them, and
checks if the average distance
is less than the minimum
distance.
If the condition is met, it opens
the cap.
It also prints the average
distance to the serial monitor
for debugging purposes.
Happy Coding!

You might also like