Артем Аш
Published © GPL3+

NOTslider

Automatic doors are a well-known solution. But here is the door of the ancient store, which I cannot open without touching! Let's solve it!

IntermediateShowcase (no instructions)8 hours1,278
NOTslider

Things used in this project

Hardware components

Grove - Ultrasonic Ranger
Seeed Studio Grove - Ultrasonic Ranger
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Arduino UNO
Arduino UNO
×1
Evaluation Board, ISL9241 Li-Ion Battery Charger
Evaluation Board, ISL9241 Li-Ion Battery Charger
×1
stepper motor
×1
reductor 1:30
×1
Wire, Wrapping Wire
Wire, Wrapping Wire
×1
li ion 18650
×4
cn6009
×1

Software apps and online services

Arduino IDE
Arduino IDE
Fusion
Autodesk Fusion

Hand tools and fabrication machines

Drill / Driver, Cordless
Drill / Driver, Cordless
milling cutter
Solder Wire, Lead Free
Solder Wire, Lead Free
Set Screw, Pack of 10
Set Screw, Pack of 10

Story

Read more

Schematics

Motor/battarey connections

Show how to connect motor with driver, arduino and battarey

ultrasonic connection

Shows how to connect ultrasonic to arduino

Code

Code

Arduino
// Include the Arduino Stepper Library
#include <Stepper.h>
const int trigPin = 3;
const int echoPin = 2;
const int detect_range = 100; // 1 m
const int door_timer = 10000;

bool is_opened;
int run_timer = 0;

long duration;
int distanceCm, distanceInch;

// Number of steps per output rotation
const int stepsPerRevolution = 200;

// Create Instance of Stepper library
Stepper myStepper(stepsPerRevolution, 4, 5, 6, 7);


void setup() {
	pinMode(trigPin, OUTPUT);
	pinMode(echoPin, INPUT);
	is_opened = false;
	myStepper.setSpeed(60);
}
void loop() {
	digitalWrite(trigPin, LOW);
	delayMicroseconds(2);
	digitalWrite(trigPin, HIGH);
	delayMicroseconds(10);
	digitalWrite(trigPin, LOW);
	duration = pulseIn(echoPin, HIGH);
	distanceCm= duration*0.034/2;

	if (distanceCm < detect_range)
	{
		open_door();
	}
	if ((run_timer > door_timer) && is_opened){
		close_door();
	}

	run_timer++;

}


void open_door(){
	is_opened = true;
	run_timer = 0;
	myStepper.step(stepsPerRevolution*5);
	delay(500);
}

void close_door(){
	is_opened = false;
	myStepper.step(-stepsPerRevolution*5);
	delay(500);

}

Credits

Артем Аш
1 project • 2 followers
Contact

Comments

Please log in or sign up to comment.