Introduction: Auto Shoes-Box
Will you think that every time you when you came back home, and you need to open the shoes- box by your self, in order to keep your shoes clean is a tuff mission? this auto shoes-box that I introduce can let you to only need to wave your hand at the shoebox, and it will open by its self.
Step 1: Prepare
First of all, you must prepare.
you will need
1. Stepper motor
2. Arduino board
3. Ultrasonic sensor
4. Scissor
5. All the things that you need to use for decoration
Step 2: Coding
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; }
//step motor function void StepMotor(int MotorStep,int MotorSpeed,int pinNumberA, int pinNumberB,int pinNumberC,int pinNumberD) { pinMode(pinNumberA, OUTPUT); pinMode(pinNumberB, OUTPUT); pinMode(pinNumberC, OUTPUT); pinMode(pinNumberD, OUTPUT); for(int i=0;i
void setup(){ // put your setup code here, to run once: digitalWrite( 6 , LOW ); //set ultrasonic sensor trigPin
}
void loop(){ // put your main code here, to run repeatedly: if ( UltrasonicSensorCM( 6 , 7 ) < 15 ) { StepMotor(512, 10, 4, 8, 12, 13); //step motor function delay( 5000 ); // waits a few milliseconds StepMotor(512, 10, 2, 8, 12, 13); //step motor function delay( 5000 ); // waits a few milliseconds } }