How to make smart Dustbin & get free Chocolate Best Arduino Project
- Get link
- X
- Other Apps
Watch video on YouTube
Click here - https://youtu.be/TET7ZB5weYo
Diagram
Arduino Code
/*
code started
diy smart chocolate dustbin
#define led = D4;
#define trigger pin = D5;
#define echo pin = D6;
#define servo pin = D9;
#define servo pin2 =D10;
code created by technical ideas yt
https://youtube.com/c/TechnicalidEas07
*/
#include <Servo.h>
Servo servo1;
Servo servo2;
int led=4;
int trig=5;
int echo=6;
int servo1_pin=9;
int servo2_pin=10;
int duration=0,dist=0;
void setup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
servo1.attach(servo1_pin);
servo2.attach(servo2_pin);
servo1.write(90);
servo2.write(90);
}
void loop()
{
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
pinMode(echo, INPUT);
duration = pulseIn(echo, HIGH);
dist = (duration*0.034) / 2; //obtain distance
if(dist<20)
{
Serial.println("Dustbin Open");
digitalWrite(led,HIGH);
servo1.write(90);
servo2.write(0);
delay(5000);
}
else
{
Serial.println("Chocolate Closed");
digitalWrite(led,LOW);
servo1.write(0);
servo2.write(90);
delay(1000);
}
}
- Get link
- X
- Other Apps
Comments