Diferencia entre revisiones de «Mecanismo de exposición para Láminas - Matilde, Andrés, Carla, Alejandra»
De Casiopea
Sin resumen de edición |
Sin resumen de edición |
||
Línea 65: | Línea 65: | ||
==Código de uso de 2 motores con 2 botones== | ==Código de uso de 2 motores con 2 botones== | ||
#include <Stepper.h> | |||
const int stepsPerRevolution = 100 ; | |||
Stepper myStepper (stepsPerRevolution, 8, 9, 10, 11); | |||
int stepCount = 0; | |||
// digital pin 2 has a pushbutton attached to it. Give it a name: | |||
int pushButton1 = 2; | |||
int pushButton2 = 4; | |||
// the setup routine runs once when you press reset: | |||
void setup() { | |||
// initialize serial communication at 9600 bits per second: | |||
Serial.begin(9600); | |||
// make the pushbutton's pin an input: | |||
pinMode(pushButton1, INPUT); | |||
pinMode(pushButton2, INPUT); | |||
} | |||
// the loop routine runs over and over again forever: | |||
void loop() { | |||
// read the input pin: | |||
int buttonState1 = digitalRead(pushButton1); | |||
int buttonState2 = digitalRead(pushButton2); | |||
// print out the state of the button: | |||
/* Serial.print("boton 1: "); | |||
Serial.println(buttonState1); | |||
Serial.print("boton 2: "); | |||
Serial.println(buttonState2); | |||
delay(100); // delay in between reads for stability | |||
*/ | |||
if(buttonState1==1){ | |||
myStepper.step(stepsPerRevolution); | |||
delay(20); | |||
} | |||
else if (buttonState2==1) { | |||
myStepper.step(-stepsPerRevolution); | |||
delay(20); | |||
} | |||
else { | |||
myStepper.step(0); | |||
} | |||
} |
Revisión del 16:44 27 may 2022
Mecanismo de exposición para Láminas, 2022 | |
Palabras Clave | objetoeducativo |
Título | Mecanismo de rieles de exposición para Láminas |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | Arduino, interacción, motor, exposición |
Período | 2022-2022 |
Asignatura | Interacción y Performatividad |
Del Curso | Interacción y Performatividad 2022 |
Carreras | Diseño, Interacción y Servicios"Interacción y Servicios" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property. |
Alumno(s) | Carla Gómez Guerra, Matilde Croxatto Ullrich, Andrés Aliaga Chandía, Alejandra Witto Royo |
Profesor | Renzo Varela |
Código para probar la funcionalidad de los 2 botones
/* DigitalReadSerial Reads a digital input on pin 2, prints the result to the Serial Monitor This example code is in the public domain. https://www.arduino.cc/en/Tutorial/BuiltInExamples/DigitalReadSerial */ // digital pin 2 has a pushbutton attached to it. Give it a name: int pushButton1 = 2; int pushButton2 = 4; // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); // make the pushbutton's pin an input: pinMode(pushButton1, INPUT); pinMode(pushButton2, INPUT); } // the loop routine runs over and over again forever: void loop() { // read the input pin: int buttonState1 = digitalRead(pushButton1); int buttonState2 = digitalRead(pushButton2); // print out the state of the button: /* Serial.print("boton 1: "); Serial.println(buttonState1); Serial.print("boton 2: "); Serial.println(buttonState2); delay(100); // delay in between reads for stability */ if(buttonState1==1){ Serial.println("mueve motor 1"); } if(buttonState2==1){ Serial.println("mueve motor 2"); } delay(100); }
Código de uso de 2 motores con 2 botones
- include <Stepper.h>
const int stepsPerRevolution = 100 ; Stepper myStepper (stepsPerRevolution, 8, 9, 10, 11); int stepCount = 0;
// digital pin 2 has a pushbutton attached to it. Give it a name: int pushButton1 = 2; int pushButton2 = 4;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second: Serial.begin(9600); // make the pushbutton's pin an input: pinMode(pushButton1, INPUT); pinMode(pushButton2, INPUT);
}
// the loop routine runs over and over again forever: void loop() {
// read the input pin: int buttonState1 = digitalRead(pushButton1); int buttonState2 = digitalRead(pushButton2); // print out the state of the button:
/* Serial.print("boton 1: ");
Serial.println(buttonState1); Serial.print("boton 2: "); Serial.println(buttonState2); delay(100); // delay in between reads for stability
- /
if(buttonState1==1){ myStepper.step(stepsPerRevolution); delay(20); }
else if (buttonState2==1) { myStepper.step(-stepsPerRevolution); delay(20); } else { myStepper.step(0); }
}