0% found this document useful (0 votes)
57 views2 pages

Código Arduino Puerta Garaje

This Arduino code controls a servo motor to open and close a door. The code attaches the servo motor to pin 3. It defines functions to open and close the door by writing incremental servo positions from 40 to 130 degrees over 500ms intervals to slowly move the door. The main loop calls the open and close functions, waiting 5 seconds between cycles to automatically open and close the door.

Uploaded by

laura ferro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views2 pages

Código Arduino Puerta Garaje

This Arduino code controls a servo motor to open and close a door. The code attaches the servo motor to pin 3. It defines functions to open and close the door by writing incremental servo positions from 40 to 130 degrees over 500ms intervals to slowly move the door. The main loop calls the open and close functions, waiting 5 seconds between cycles to automatically open and close the door.

Uploaded by

laura ferro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Vídeo:https://www.youtube.com/watch?

v=LBZjtVD7hIA&t=350s&pp=ygUPcHVlcnRhIGFyZHVpbm8g

Código:
#include<Servo.h>

Servo motor;
void setup() {

motor.attach(3);

}
void loop() {
AbrirPuerta();
CerrarPuerta();
delay(5000);

}
void AbrirPuerta(){

digitalWrite(4,LOW);
digitalWrite(5,HIGH);

motor.write(40);
delay(500);
motor.write(50);
delay(500);
motor.write(60);
delay(500);
motor.write(70);
delay(500);
motor.write(80);
delay(500);
motor.write(90);
delay(500);
motor.write(100);
delay(500);
motor.write(110);
delay(500);
motor.write(120);
delay(500);
motor.write(130);
delay(500);

digitalWrite(4,HIGH);
digitalWrite(5,LOW);
delay(5000);
}
void CerrarPuerta(){

digitalWrite(4,LOW);
digitalWrite(5,HIGH);
motor.write(130);
delay(500);
motor.write(120);
delay(500);
motor.write(110);
delay(500);
motor.write(100);
delay(500);
motor.write(90);
delay(500);
motor.write(80);
delay(500);
motor.write(70);
delay(500);
motor.write(60);
delay(500);
motor.write(50);
delay(500);
motor.write(40);
delay(500);
motor.write(30);
delay(500);
motor.write(20);
delay(500);
motor.write(10);
delay(500);
digitalWrite(4,LOW);

digitalWrite(5,HIGH);

You might also like