Final Project_Interactive Mirror

Interactive Mirror

-Materials:

  • Wood
  • Glass
  • Servo
  • Motor Stepper
  • Arduino
  • Wire
  • Proto Board

Code:

int PULSADOR = 2; //BOTON
int MOTOR=3;
int estado=LOW;

#include <Servo.h> //SERVO
Servo name_servo;
int servo_position = 0;

#include <Stepper.h> //MOTOR 1

Stepper motor1(2048,8,10,9,11); //pasos completos

Stepper motor2(2048,4,5,6,7); //pasos completos //MOTOR 2

void setup (){
motor1.setSpeed(3); // en RPM (valores de 1,2 o 3 para 28BYJ-48) //MOTOR 1
motor2.setSpeed(3); // en RPM (valores de 1,2 o 3 para 28BYJ-48) //MOTOR 2

pinMode(PULSADOR,INPUT_PULLUP); //BOTON
pinMode(MOTOR,OUTPUT);
digitalWrite(MOTOR,LOW);

name_servo.attach (12); //SERVO

}

void loop() {

for(servo_position = 0; servo_position <=180; servo_position +=1){ //SERVO

name_servo.write (servo_position);
delay(10);

}

for (servo_position=180; servo_position >=0; servo_position -=1){

name_servo.write (servo_position);
delay(10);
}

motor1.step(2048); //cantidad de pasos //MOTOR 1
delay(2000);
motor1.step(-2040); //cantidad de pasos
delay(2000);

motor2.step(2048); //cantidad de pasos //MOTOR 2
delay(2000);
motor2.step(2040); //cantidad de pasos
delay(2000);

while(digitalRead(PULSADOR)==LOW); //BOTON
estado = digitalRead(MOTOR);
digitalWrite(MOTOR,!estado);
while(digitalRead(PULSADOR)==HIGH);