🧠 How to Make a Smart Dustbin with Arduino on Tinkercad – Step-by-Step Guide
👨💻 Code Designed By: Rajkamal
🚀 Project Developed By: Kamaldnp (kamaldnp.com)
🔗 Tinkercad Project: Click to View
🎮 YouTube Tutorial: Watch the Video
🗖️ Step-by-Step Instructions
🛠️ Step-by-Step Guide
✅ Step 1: Open Tinkercad
Visit: https://www.tinkercad.com
Create a free account or log in.
Go to Circuits → Click “Create New Circuit”.
✅ Step 2: Add Components to the Workspace
Drag and drop the following components from the components panel:
Arduino UNO
Ultrasonic Sensor (HC-SR04)
Servo Motor (e.g., SG90)
LED (optional)
Breadboard (optional, for clean wiring)
Jumper wires
✅ Step 3: Wiring – Connect All Components
🔌 Ultrasonic Sensor (HC-SR04):
Sensor Pin | Arduino Pin |
---|---|
VCC | 5V |
GND | GND |
Trig | D5 |
Echo | D6 |
🔄 Servo Motor:
Servo Wire | Arduino Pin |
---|---|
VCC (Red) | 5V |
GND (Brown/Black) | GND |
Signal (Yellow/Orange) | D7 |
💡 LED (Optional):
LED Pin | Arduino Pin |
---|---|
Long leg (+) | D10 via 220Ω resistor |
Short leg (-) | GND |
✅ Step 4: Upload Code to Arduino
Switch from Blocks to Text and paste the code below. Or click to download:
Copy & Paste Arduino Code:
Code copied!
/* Smart Dustbin Arduino Code
Code Designed By: Rajkamal
Project Developed By: Kamaldnp (kamaldnp.com)
Tinkercad Project: https://www.tinkercad.com/things/9SmkCNptuai-smart-dustbin
YouTube Video: https://www.youtube.com/watch?v=e9D5XSDnVWo */
#include
Servo servo;
const int trigPin = 5;
const int echoPin = 6;
const int servoPin = 7;
const int ledPin = 10;
long duration, distance;
long readings[3];
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(ledPin, OUTPUT);
servo.attach(servoPin);
servo.write(0); // Close lid on start
delay(1000);
servo.detach();
}
long getDistance() {
digitalWrite(ledPin, HIGH);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
return (duration / 2) / 29.1;
}
void loop() {
for (int i = 0; i < 3; i++) {
readings[i] = getDistance();
delay(50);
}
distance = (readings[0] + readings[1] + readings[2]) / 3;
if (distance < 50) {
servo.attach(servoPin);
servo.write(0); // Open lid
delay(3000);
servo.write(150); // Close lid
delay(1000);
servo.detach();
}
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(200);
}
…