Sie sind auf Seite 1von 7

- UTN FRSF - OTRA FORMA DE APRENDER - DESARROLLO DE SISTEMAS DE CONTOL BASADOS EN PLATAFORMA ARDUINO - PRACTICO I - ELECTRONICA - PROGRAMACION - SIMULACION -

a. Utilizando 123D Circuits (o el IDE de Arduino + Fritzing), implementar los siguientes circuitos.
Importante: los 3 ejercicios se debern respetar los pines que se muestran en las imgenes.
Entregar en un archivo comprimido (.rar) con sus respectivos cdigos y una imagen o captura
de pantalla del circuito.
a. Parpadeo de un led con periodos de 800mS encendido y 400mS apagado.
Elementos a utilizar:
1 LED
1 Resistencia (220 )
1 Placa Arduino (pin 2)

- UTN FRSF - OTRA FORMA DE APRENDER - DESARROLLO DE SISTEMAS DE CONTOL BASADOS EN PLATAFORMA ARDUINO - PRACTICO I - ELECTRONICA - PROGRAMACION - SIMULACION -

Esquema con Fritzing:

Cdigo con IDE Arduino:

- UTN FRSF - OTRA FORMA DE APRENDER - DESARROLLO DE SISTEMAS DE CONTOL BASADOS EN PLATAFORMA ARDUINO - PRACTICO I - ELECTRONICA - PROGRAMACION - SIMULACION -

b. Se deber obtener una lectura (analgica) desde un potencimetro el cual nos activar de 1 a
5 leds, para esto se necesitar utilizar la funcin map().
Aclaracin: cuando la lectura en el potencimetro sea 0v estarn todos los leds apagados,
cuando la lectura sea 5v estarn todos prendidos, y los valores intermedios activarn
secuencialmente los dems leds. Elementos a utilizar:
5 LED
5 Resistencias (220 )
1 Potencimetro
1 Placa Arduino (pines 2-6 y A0)

- UTN FRSF - OTRA FORMA DE APRENDER - DESARROLLO DE SISTEMAS DE CONTOL BASADOS EN PLATAFORMA ARDUINO - PRACTICO I - ELECTRONICA - PROGRAMACION - SIMULACION -

Cdigo IDE Arduino:


/*Rivamar, Alfredo. Prctico 1b Arduino UTN FRSF
*/
// Definicin de constantes:
const int analogPin = A0; // pin de conexin del potencimetro
const int ledCount = 5; // por 5 LED conectados
int ledPins[] = {2, 3, 4, 5, 6}; // array conteniendo nmeros de pines de conexin de los LED
void setup() {
//lazo con el nmero de pin y envo a la salida del array:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop() {
//lectura del potencimetro:
int sensorReading = analogRead(analogPin);
//convertir el resultado a un rango entre 0 y el nmero de LED (5):
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);
// lazo sobre el array de LED:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
//si el ndice de elementos del array es menor que ledLevel, encender este pin:
if (thisLed < ledLevel) {
digitalWrite(ledPins[thisLed], HIGH);
}
//apagar todos los pines ms altos que ledLevel:
else {
digitalWrite(ledPins[thisLed], LOW);
}
}
}

- UTN FRSF - OTRA FORMA DE APRENDER - DESARROLLO DE SISTEMAS DE CONTOL BASADOS EN PLATAFORMA ARDUINO - PRACTICO I - ELECTRONICA - PROGRAMACION - SIMULACION -

c. Mostrar secuencialmente (mediante 8 leds) el cdigo binario natural de 8 bits con una
secuencia de 500mS. Se deber utilizar un bucle for() para aumentar el nmero, la funcin
shiftOut() y un registro de desplazamiento. Adems, indicara en el monitor serial, el numero
decimal que est contando, siempre escribiendo en lnea nueva.
Elementos a utilizar:
1 Placa Arduino (pines 8 ST_CP, 11- DS y 12 - SH_CP)
1 74HC595
8 LED
8 resistencias.

- UTN FRSF - OTRA FORMA DE APRENDER - DESARROLLO DE SISTEMAS DE CONTOL BASADOS EN PLATAFORMA ARDUINO - PRACTICO I - ELECTRONICA - PROGRAMACION - SIMULACION -

Cdigo IDE Arduino:


/*Rivamar, Alfredo. Prctico 1c Arduino UTN FRSF
*/
//Pin 8 Arduino conectado al Pin 12 del 74HC595 (Latch)
int latchPin = 8;
//Pin 12 Arduino conectado al Pin 11 del 74HC595 (Clock)
int clockPin = 12;
//Pin 11 Arduino conectado al Pin 14 del 74HC595 (Data)
int dataPin = 11;
void setup() {
//configurar pines como salidas (output)
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
//contar desde 0 a 255
for (int i = 0; i < 256; i++) {
//poner latchPin en bajo para permitir el flujo de datos
digitalWrite(latchPin, LOW);
shiftOut(i);
//poner latchPin en alto para cerrar el registro y enviar datos
digitalWrite(latchPin, HIGH);
delay(500);
}
}
void shiftOut(byte dataOut) {
boolean pinState;
//registro de desplazamiento listo para enviar datos
6

- UTN FRSF - OTRA FORMA DE APRENDER - DESARROLLO DE SISTEMAS DE CONTOL BASADOS EN PLATAFORMA ARDUINO - PRACTICO I - ELECTRONICA - PROGRAMACION - SIMULACION -

digitalWrite(dataPin, LOW);
digitalWrite(clockPin, LOW);
for (int i=0; i<=7; i++) {
//set clockPin en LOW previo enviar un bit
digitalWrite(clockPin, LOW);
//si el valor de DataOut y (AND lgico) en bitmask es verdadero, poner pinState en 1 (HIGH)
if ( dataOut & (1<<i) ) {
pinState = HIGH;
}
else {
pinState = LOW;
}
//poner dataPin en HIGH o en LOW dependiendo de pinState
digitalWrite(dataPin, pinState);
digitalWrite(clockPin, HIGH);
}
//detener el desplazamiento de datos
digitalWrite(clockPin, LOW);
}

Das könnte Ihnen auch gefallen