Upload
ryan-morgan
View
25
Download
0
Embed Size (px)
Citation preview
Ing. MecatrónicaInstrumentación
virtualPractica N° 1
Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEn esta primera práctica se tiene como finalidad el asimilar como es el funcionamiento de un Arduino desde el programa y su lógica programable hasta
de forma física como son sus entradas y salidas para implementarse en un circuito eléctrico.
La función de este código no es más que la de prender un LED y con la ayuda de los “delays” modular la velocidad con la que enciende un LED.
PRACTICA N°1
CONCLUSION
Gracias a la función del código, más específicamente del delay el LED prende y a paga a 100mili segundos.
Instrumentación virtual
Practica N° 2Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEsta práctica es muy precisa a la uno lo único que la diferencia son los valores del delay , recordemos que un delay equivale a milésimas de segundos.
COCLUSION
El objetivo de la práctica fue cumplido ya que el led prendía y apagaba cada 10 milisegundos que fue el valor preestablecido en el código. Se recomienda jugar con los valores para su mejor entendimiento en el código.
Instrumentación virtual
Practica N° 3Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVO
Ya que aprendimos a usar el delay lo modificaremos a nuestro gusto poniendo 1000 para el prendido y 100 para el apagado.
CONCLUSIÓNEl delay no solo sirve para apagar y prender el led lo más rápido posible sino que también nos sirve para intercambiarlos, es decir puedo prender más rápido y que se apague más lento.
Instrumentación virtual
Practica N° 4Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEn esta práctica se le asigna el delay dos tiempos diferentes, tanto en el apagado como en el encendido, cada uno con sus respectivos valores (100) y (1000).
El led se puede conectar directo o con el uso del protoboard
CONCLUSIÓNLa práctica se concluyó de forma satisfactoria comprobando el funcionamiento de delay.
Instrumentación virtual
Practica N° 5Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVORealizar un programa que encienda y apague un led con una velocidad de 1000 microsegundos.
CODIGO DEL ARDUINO
/* Blink
Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ // Pin 13 has an LED connected on most Arduino boards.// give it a name:int led = 13;
// the setup routine runs once when you press reset:void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); }
// the loop routine runs over and over again forever:void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second /* aqui se queda encendido*/ digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(10000); // wait for a second // wait for a second /* aqui inicia el conteo */ digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second /* aqui se apaga */ digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(10000); // wait for a second
El led prende directamente conectado en el Arduino en el pin 13 y el grand
CONCLUSIONEn la práctica de forma física pude observar que el led enciende 10 veces y después apaga, logrando la efectividad del programa en arduino.
Esto quiere decir que el tiempo que le asignamos en el programa se cumplió.
Instrumentación virtual
Practica N° 6Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOSe pedirá en esta práctica que el programa de 20 pulsos en led y se queda encendido, también que cuando encienda parpadea 1000 veces y cuando acabe de igual forma.
CÓDIGO ARDUINO
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain.
*/ // Pin 13 has an LED connected on most Arduino boards.// give it a name:int led = 13;
// the setup routine runs once when you press reset:void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); }
// the loop routine runs over and over again forever:void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second /* aqui inicia el conteo */ digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second /* aqui se apaga */ digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(10000); // wait for a second
}
CONCLUSIONEl parpadeo de los leds se llevó de forma correcta por lo que el programa no tuvo error.
Instrumentación virtual
Practica N° 7Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEn esta práctica se encenderá el led con la ayuda de los delays.
CODIGO ARDUINO
const int led = 13; //led pata 13void setup ()
{pinMode (led, OUTPUT); // Digital, como salida}
void loop (){digitalWrite (led, HIGH); //ONdelay(2000); //esperadigitalWrite (led, LOW); //OFFdelay(250); //ESPERA
digitalWrite (led, HIGH); //ONdelay(1000); //esperadigitalWrite (led, LOW); //OFFdelay(250); //ESPERA
digitalWrite (led, HIGH); //ONdelay(100); //esperadigitalWrite (led, LOW); //OFFdelay(250); //ESPERA
digitalWrite (led, HIGH); //ONdelay(10); //esperadigitalWrite (led, LOW); //OFFdelay(250); //ESPERA
}
CONCLUSIONEl arduino trabaja de forma correcta con el encendió del led.
Instrumentación virtual
Practica N° 8Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEl objetivo de esta práctica es que tengamos diferentes salidas tales como la 13 y 12 y se realice una secuencia de encendido de delay 2000.
CODIGO ARDUINO
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int led2 = 12;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
pinMode(led2,OUTPUT);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(10); // wait for a second
}
CONCLUSIONEl parpadeo del led fue el establecido y las entradas y salidar son la 13 y12.
Instrumentación virtual
Practica N° 9Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEl objetivo de esta práctica es hacer una secuencia de encendido donde se utilizan 5 led y su función es un encendido de 1000 milisegundos y un apagado de 1000 milisegundos
CODIGO ARDUINO
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
const int led1 = 13;
const int led2 = 12;
const int led3 = 8;
const int led4 = 7;
const int led5 = 4;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
pinMode (led1, OUTPUT);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led2, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led3, OUTPUT);
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led4, OUTPUT);
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led5, OUTPUT);
}
CONCLUSION
La secuencia de leds prendió de la manera ordenada que se le notifico por lo que la práctica queda completa.
Instrumentación virtual
Practica N° 10Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEl objetivo es hacer una secuencia de encendido donde se utilizan 5 led y su función es un encendido de 1000 milisegundos y un apagado de 1000 milisegundos donde se realiza de forma ordena con la ayuda de un Arduino.
CODIGO ARDUINO
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
const int led1 = 13;
const int led2 = 12;
const int led3 = 8;
const int led4 = 7;
const int led5 = 4;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
pinMode (led5, OUTPUT);
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led4, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led3, OUTPUT);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led2, OUTPUT);
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led1, OUTPUT);
}
CONCLUSIONLa cadena de leds prende de forma ordenada secuencialmente.
Instrumentación virtual
Practica N° 11Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEn esta práctica y es una secuencia de encendido donde se utilizan 3 led´s y su función es un encendido de 1000 milisegundos y un apagado de 1000 milisegundos donde su secuencia es de encender uno si y uno n.
CODIGO ARDUINO
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 4;
int led2 = 8;
int led3 = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode (led2, OUTPUT);
pinMode (led3, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(10); // wait for a second
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(10);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(10);
}
CONCLUSIONEl arduino trabaja de forma correcta con el encendió de uno sí y otro no. F
Instrumentación virtual
Practica N° 12Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEn esta práctica es una secuencia de encendido donde se utilizan 5 led y su función es un encendido de 1000 milisegundos y un apagado de 1000 milisegundos donde su secuencia es de encender uno si y uno no.Igual a la 11 solo cambian 1-3-5 a 5-3-1).
CODIGO ARDUINO
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int led2 = 8;
int led3 = 4;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode (led2, OUTPUT);
pinMode (led3, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(10); // wait for a second
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(10);
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(10);
}
CONCLUSIONEl arduino trabaja de forma correcta con el encendió de uno sí y otro no.
Instrumentación virtual
Practica N° 13Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEsta práctica consiste en incluir de la practica 9 a la 11.
CODIGO ARDUINO
const int led1 = 13;
const int led2 = 12;
const int led3 = 8;
const int led4 = 7;
const int led5 = 4;
// La rutina de instalación se ejecuta una vez al presionar reinicio:
void setup() {
// inicializar el pin digital como salida.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}
//la rutina bucle se ejecuta una y otra vez para siempre:
void loop() {
digitalWrite(led1, HIGH); // Enciende el LED (ALTA es el nivel de tensión)
delay(1000); // esperar un segundo
digitalWrite(led1, LOW); // apagar el LED por lo que la tensión BAJA
delay(1000); // esperar un segundo
pinMode (led1, OUTPUT);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led2, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led3, OUTPUT);
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led4, OUTPUT);
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led5, OUTPUT);
//practica 10.
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led5, OUTPUT);
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led4, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led3, OUTPUT);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led2, OUTPUT);
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
pinMode (led1, OUTPUT);
//practica 11.
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led5, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led3, OUTPUT);
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
pinMode (led1, OUTPUT);
//practica 12.
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
pinMode (led1, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led3, OUTPUT);
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(1000);
pinMode (led5, OUTPUT);
}
CONCLUSIONEn programa funciona bien con los tiempos del delay y la cadena. Utilizando 5 led´s.
Instrumentación virtual
Practica N° 14Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVO El programa hace, y es una secuencia de encendido donde se utilizan 5 led y su funcionamiento es juntar las prácticas mencionadas anteriormente y llevarlas a cabo.
CODIGO ARDUINO
const int led1 = 13;
const int led2 = 12;
const int led3 = 8;
const int led4 = 7;
const int led5 = 4;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
pinMode (led1, OUTPUT);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led2, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led3, OUTPUT);
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led4, OUTPUT);
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led5, OUTPUT);
//practica 10.
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led5, OUTPUT);
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led4, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led3, OUTPUT);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led2, OUTPUT);
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
pinMode (led1, OUTPUT);
//practica 11.
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led5, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led3, OUTPUT);
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
pinMode (led1, OUTPUT);
//practica 12.
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
pinMode (led1, OUTPUT);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led3, OUTPUT);
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led5, OUTPUT);
}
CONCLUSION
En los pines 13, 12, 8, 7, 4 se cargan las secuencias que se van a realizar con 5 led, manteniendo el delay (más rápido o entre más tenga es más lento el anterior fue de 1000 en encendido y apagado 1000)
Instrumentación virtual
Practica N° 15Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEl objetivo de esta práctica es el de habilitar los pines 13, 12, 8, 7, 4 y unimos las practicas anteriores de la 9 a la 12 donde las secuencias se van a realizar con 5 led, la practica 9 es una secuencia con 5 led donde van a encender de forma ordenada de izquierda a derecha.
CODIGO ARDUINO
const int led1 = 13;
const int led2 = 12;
const int led3 = 8;
const int led4 = 7;
const int led5 = 4;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
for (int i=0; i<=9;i++)
{
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
pinMode (led1, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led2, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led3, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led4, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led5, OUTPUT);
}
//practica 10.
for (int i=0; i<=9;i++)
{
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led5, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led4, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led3, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led2, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
pinMode (led1, OUTPUT);
}
//practica 11.
for (int i=0; i<=9;i++)
{
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led5, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led3, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
pinMode (led1, OUTPUT);
}
//practica 12.
for (int i=0; i<=9;i++)
{
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
pinMode (led1, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led3, OUTPUT);
}
for (int i=0; i<=9;i++)
{
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
delay(100);
pinMode (led5, OUTPUT);
}
}
CONCLUSIONEn secuencial de leds prende de la forma en q se programó el código.
Instrumentación virtual
Practica N° 16Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOSe realiza un rayo de luz, o más poéticamente, una estrella fugaz, moviéndose a través de una línea de LED-s. Podremos configurar tanto la velocidad de la estrella, así como la longitud de la cola utilizando los delays
CODIGO ARDUINO
int pinArray [] = { 2,3,4,5,6,7,8,9,10,11,12 };
int controlLed = 13; // LED de control
int waitNextLed = 100; // Tiempo antes de encender el siguiente LED
// Número de LED-s que permanecen encendidos antes de empezar a apagarlos para
//formar la cola
int tailLength = 4;
// Número de LED-s conectados (que es también el tamaño del array)
int lineSize = 11;
void setup() // Configuración de los PIN-es como salida digital
{
int i;
pinMode (controlLed, OUTPUT);
for (i=0; i< lineSize; i++)
{
pinMode(pinArray[i], OUTPUT);
}
}
void loop()
{
int i;
// Se establece la longitud de la cola en un contador
int tailCounter = tailLength;
// Se enciende el LED de control para indicar el inicio del loop
digitalWrite(controlLed, HIGH);
for (i=0; i<lineSize; i++)
{
digitalWrite(pinArray[i],HIGH); // Se encienden consecutivamente los LED
// Esta variable de tiempo controla la velocidad a la que se mueve la estrella
delay(waitNextLed);
if (tailCounter == 0)
{
// Se apagan los LED-s en función de la longitud de la cola.
digitalWrite(pinArray[i-tailLength],LOW);
}
else
if (tailCounter > 0)
tailCounter--;
}
for (i=(lineSize-tailLength); i<lineSize; i++)
{
digitalWrite(pinArray[i],LOW); // Se apagan los LED
// Esta variable de tiempo controla la velocidad a la que se mueve la estrella
delay(waitNextLed);
}
}
COCLUSIONSe puede observar el funcionamiento del programa imitando una estrella fugaz, es decir el tiempo en que los led prenden es muy rápido.
Instrumentación virtual
Practica N° 17Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVO Se realiza la practica 10 solo que esta vez se le añadirán más leds y los tiempos de delay cambiaran para que aun siga pareciendo una estrella fugaz.
CODIGO ARDUINO
int controlLed = 13; // LED de control
int waitNextLed = 100; // Tiempo antes de encender el siguiente LED
// Número de LED-s que permanecen encendidos antes de empezar a apagarlos para
//formar la cola
int tailLength = 4;
// Número de LED-s conectados (que es también el tamaño del array)
int lineSize = 11;
void setup() // Configuración de los PIN-es como salida digital
{
int i;
pinMode (controlLed, OUTPUT);
for (i=0; i< lineSize; i++)
{
pinMode(pinArray[i], OUTPUT);
}
}
void loop()
{
int i;
// Se establece la longitud de la cola en un contador
int tailCounter = tailLength;
// Se enciende el LED de control para indicar el inicio del loop
digitalWrite(controlLed, HIGH);
for (i=0; i<lineSize; i++)
{
digitalWrite(pinArray[i],HIGH); // Se encienden consecutivamente los LED
// Esta variable de tiempo controla la velocidad a la que se mueve la estrella
delay(waitNextLed);
if (tailCounter == 0)
{
// Se apagan los LED-s en función de la longitud de la cola.
digitalWrite(pinArray[i-tailLength],LOW);
}
else
if (tailCounter > 0)
tailCounter--;
}
for (i=(lineSize-tailLength); i<lineSize; i++)
{
digitalWrite(pinArray[i],LOW); // Se apagan los LED
// Esta variable de tiempo controla la velocidad a la que se mueve la estrella
delay(waitNextLed);
}
}
CONCLUSIÓNEl código hace que en forma física a los leds imiten una serie muy parecida a una estrella fugaz.
Instrumentación virtual
Practica N° 18Ortega Morales Sabino de Jesús
Grupo:7M1
OBJETIVOEsta práctica se adjunta las prácticas 13 y 17(que es un conjunto de todas las prácticas).
CODIGO ARDUINO
const int led1 = 13; //LED pata 13
const int led2 = 12; //LED pata 12
const int led3 = 11; //LED pata 11
const int led4 = 10; //LED pata 10
const int led5 = 9; //LED pata 9
int pinArray [] = { 3,4,5,6,7,8,9,10,11,12,13,12,11,10,9,8,7,6,5,4,3};
int controlLed = 3; // LED de control
int waitNextLed = 100; // Tiempo antes de encender el siguiente LED
// Número de LED-s que permanecen encendidos antes de empezar a apagarlos para
//formar la cola
int tailLength = 3;
// Número de LED-s conectados (que es también el tamaño del array)
int lineSize = 22;
void setup ()
{
pinMode (led1, OUTPUT); //Digital, como salida
pinMode (led2, OUTPUT); //Digital, como salida
pinMode (led3, OUTPUT); //Digital, como salida
pinMode (led4, OUTPUT); //Digital, como salida
pinMode (led5, OUTPUT); //Digital, como salida
int i;
pinMode (controlLed, OUTPUT);
for (i=0; i< lineSize; i++)
{
pinMode(pinArray[i], OUTPUT);
}
}
void loop ()
{
//pract 9
digitalWrite (led1, HIGH); //ON
delay(1000); //espera
digitalWrite (led1, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led2, HIGH); //ON
delay(1000); //espera
digitalWrite (led2, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led3, HIGH); //ON
delay(1000); //espera
digitalWrite (led3, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led4, HIGH); //ON
delay(1000); //espera
digitalWrite (led4, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led5, HIGH); //ON
delay(1000); //espera
digitalWrite (led5, LOW); //OFF
delay(250); //ESPERA
//pract10
digitalWrite (led5, HIGH); //ON
delay(1000); //espera
digitalWrite (led5, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led4, HIGH); //ON
delay(1000); //espera
digitalWrite (led4, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led3, HIGH); //ON
delay(1000); //espera
digitalWrite (led3, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led2, HIGH); //ON
delay(1000); //espera
digitalWrite (led2, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led1, HIGH); //ON
delay(1000); //espera
digitalWrite (led1, LOW); //OFF
delay(250); //ESPERA
//pract 11
digitalWrite (led5, HIGH); //ON
delay(1000); //espera
digitalWrite (led5, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led3, HIGH); //ON
delay(1000); //espera
digitalWrite (led3, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led1, HIGH); //ON
delay(1000); //espera
digitalWrite (led1, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led1, HIGH); //ON
delay(1000); //espera
digitalWrite (led1, LOW); //OFF
delay(250); //ESPERA
//pract12
digitalWrite (led3, HIGH); //ON
delay(1000); //espera
digitalWrite (led3, LOW); //OFF
delay(250); //ESPERA
digitalWrite (led5, HIGH); //ON
delay(1000); //espera
digitalWrite (led5, LOW); //OFF
delay(250); //ESPERA
int i;
// Se establece la longitud de la cola en un contador
int tailCounter = tailLength;
// Se enciende el LED de control para indicar el inicio del loop
digitalWrite(controlLed, HIGH);
for (i=0; i<lineSize; i++)
{
digitalWrite(pinArray[i],HIGH); // Se encienden consecutivamente los LED
// Esta variable de tiempo controla la velocidad a la que se mueve la estrella
delay(waitNextLed);
if (tailCounter == 0)
{
// Se apagan los LED-s en función de la longitud de la cola.
digitalWrite(pinArray[i-tailLength],LOW);
}
else
if (tailCounter > 0)
tailCounter--;
}
for (i=(lineSize-tailLength); i<lineSize; i++)
{
digitalWrite(pinArray[i],LOW); // Se apagan los LED
// Esta variable de tiempo controla la velocidad a la que se mueve la estrella
delay(waitNextLed);
}
}
COCLUSION
Se puede observar el funcionamiento del programa imitando una estrella fugaz, es decir el tiempo en que los led prenden es muy rápido, y también las animaciones así como la unión de las practicas 9,10,11,12,13 (antes ya explicadas).