Brilliant! I love that your daughter helped too : ) I watched another video of a bin done , but they had the stuff wired inside the bin- this is much better : )
why is the servo motors red wire and ultrasonic sensor vcc conected to the same place in the arduino 5v??how am i supposed to connect ?,also can u please show the wiring part more clearly?,ty
/********* SparkLabz - Motion activated bin *********/ #include #define TRIG 10 #define ECHO 9 #define SERVO A1 // Ultrasonic sensor variables long duration; float distance; // Servo variables Servo myServo; void setup() { Serial.begin(115200); // Start serial communication pinMode(TRIG, OUTPUT); // Set trigger pin as an Output pinMode(ECHO, INPUT); // Set echo pin as an Input myServo.attach(SERVO); // Attach servo pin } void loop() { // Clear trigger pin digitalWrite(TRIG, LOW); delayMicroseconds(5); // Set triggerPin to HIGH for 10uS digitalWrite(TRIG, HIGH); delayMicroseconds(10); digitalWrite(TRIG, LOW); // Read echoPin and get sound wave travel time in microseconds duration = pulseIn(ECHO, HIGH); // Calculate distance distance = (duration/2.0)/29.0; // Prints distance to Serial Monitor Serial.print("Distance (cm): "); Serial.println(distance); if (distance < 50) { // If something is closer than 50cm, open the bin myServo.write(180); delay(5000); } else { myServo.write(0); delay(15); } delay(100); }
/********* SparkLabz - Motion activated bin *********/ #include #define TRIG 10 #define ECHO 9 #define SERVO A1 // Ultrasonic sensor variables long duration; float distance; // Servo variables Servo myServo; void setup() { Serial.begin(115200); // Start serial communication pinMode(TRIG, OUTPUT); // Set trigger pin as an Output pinMode(ECHO, INPUT); // Set echo pin as an Input myServo.attach(SERVO); // Attach servo pin } void loop() { // Clear trigger pin digitalWrite(TRIG, LOW); delayMicroseconds(5); // Set triggerPin to HIGH for 10uS digitalWrite(TRIG, HIGH); delayMicroseconds(10); digitalWrite(TRIG, LOW); // Read echoPin and get sound wave travel time in microseconds duration = pulseIn(ECHO, HIGH); // Calculate distance distance = (duration/2.0)/29.0; // Prints distance to Serial Monitor Serial.print("Distance (cm): "); Serial.println(distance); if (distance < 50) { // If something is closer than 50cm, open the bin myServo.write(180); delay(5000); } else { myServo.write(0); delay(15); } delay(100); }
Brilliant! I love that your daughter helped too : )
I watched another video of a bin done , but they had the stuff wired inside the bin- this is much better : )
Hello!, can you list the materials needed for this project?, like what type of wires do I need?
why is the servo motors red wire and ultrasonic sensor vcc conected to the same place in the arduino 5v??how am i supposed to connect ?,also can u please show the wiring part more clearly?,ty
Can you help me in programming.....can you send me the program of this video
/*********
SparkLabz - Motion activated bin
*********/
#include
#define TRIG 10
#define ECHO 9
#define SERVO A1
// Ultrasonic sensor variables
long duration;
float distance;
// Servo variables
Servo myServo;
void setup() {
Serial.begin(115200); // Start serial communication
pinMode(TRIG, OUTPUT); // Set trigger pin as an Output
pinMode(ECHO, INPUT); // Set echo pin as an Input
myServo.attach(SERVO); // Attach servo pin
}
void loop() {
// Clear trigger pin
digitalWrite(TRIG, LOW);
delayMicroseconds(5);
// Set triggerPin to HIGH for 10uS
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
// Read echoPin and get sound wave travel time in microseconds
duration = pulseIn(ECHO, HIGH);
// Calculate distance
distance = (duration/2.0)/29.0;
// Prints distance to Serial Monitor
Serial.print("Distance (cm): ");
Serial.println(distance);
if (distance < 50) {
// If something is closer than 50cm, open the bin
myServo.write(180);
delay(5000);
} else {
myServo.write(0);
delay(15);
}
delay(100);
}
Hi, your video mentions that you'll pin the code in the comments, but I can see it. Are you able to provide a link?
/*********
SparkLabz - Motion activated bin
*********/
#include
#define TRIG 10
#define ECHO 9
#define SERVO A1
// Ultrasonic sensor variables
long duration;
float distance;
// Servo variables
Servo myServo;
void setup() {
Serial.begin(115200); // Start serial communication
pinMode(TRIG, OUTPUT); // Set trigger pin as an Output
pinMode(ECHO, INPUT); // Set echo pin as an Input
myServo.attach(SERVO); // Attach servo pin
}
void loop() {
// Clear trigger pin
digitalWrite(TRIG, LOW);
delayMicroseconds(5);
// Set triggerPin to HIGH for 10uS
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
// Read echoPin and get sound wave travel time in microseconds
duration = pulseIn(ECHO, HIGH);
// Calculate distance
distance = (duration/2.0)/29.0;
// Prints distance to Serial Monitor
Serial.print("Distance (cm): ");
Serial.println(distance);
if (distance < 50) {
// If something is closer than 50cm, open the bin
myServo.write(180);
delay(5000);
} else {
myServo.write(0);
delay(15);
}
delay(100);
}
@@SparkLabz Ta very much.
@@SparkLabz
@@SparkLabz Thanks homie, very intimate surprise is on the way :)
Shits fire bro mind if i borrow it ? Send me the code rq please and thank you.
fygfl
This is rubbish. AHA