Introduction: Automatic Tissue Opener 2.0

This product imitated the function of "Automatic Tissue Opener 2.0" from angelwanggg (https://www.instructables.com/Automatic-Tissue-Opener/) The tissue case can prevent dust and germs from contacting to tissue. Due to the pandemic, people care more about sanitation and want to lower the risk of touching public appliances. The Automatic Tissue Opener 2.0 can solve people's problem!!! (it's prettier than Atomatic Tissue Opener 1.0)

Supplies

Arduino Leonardo x1 Breadboard x1 USB Cable x1 HC-SR04 Ultrasonic Module Distance Sensor x1 Servo Motor x1 Male-to-male jumper wires x many Male-to-Female jumper wires x4 Tissue box x1 Tapes Corrugated boards (Utility knife and Scissors)

Step 1: Connect the Materials With the Arduino Leonardo and Breadboard

Step 2: Code

#include

int UltrasonicSensorCM(int trigPin, int echoPin) //Ultrasonic Sensor Code Auto Generated Return CM max distance 200

{

long duration;

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(20);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

duration = duration / 59;

if ((duration < 2) || (duration > 200)) return false;

return duration;

}

Servo servo_pin_2; // create servo object to control a servo

void setup(){ // put your setup code here, to run once:

digitalWrite( 6 , LOW ); //set ultrasonic sensor trigPin

servo_pin_2.attach(2); // attaches the servo on pin to the servo object

}

void loop(){ // put your main code here, to run repeatedly:

if ( UltrasonicSensorCM( 6 , 7 ) <= 15 ) { //當手在15公分或以內的距離感應到超音波感測器

delay( 4000 ); // 伺服馬達會等待兩秒

servo_pin_2.write( 30 ); // 轉30度(打開蓋子)

delay( 4000 ); // 等待四秒後 servo_pin_2.write( 130 ); // 馬達會往下轉130度,也就是蓋子會關上

delay( 4000 ); // 再等待四秒,又可以重新再用手感應然後打開蓋子

}

}

Step 3: Make the Box