Está en la página 1de 4

UNIVERSIDAD DISTRITAL FRANCISCO JOSE DE CALDAS

FACULTAD DE INGENIERIA
INGENIERIA ELECTRICA
PRACTICA 4
INTERRUPCIONES

Objetivo: observar la importancia de las interrupciones.

Implementar el siguiente cogido que controla el estado de un LED mediante


un pulsador

int pbIn = 2;
int ledOut = 4;
int state = LOW;

// Digital input on pin 2


// The output LED pin
// The input state

void setup()
{
// Set up the digital Pin 2 to an Input and Pin 4 to an Output
pinMode(pbIn, INPUT);
pinMode(ledOut, OUTPUT);
}

void loop()
{
state = digitalRead(pbIn);

//Read the button

digitalWrite(ledOut, state);

//write the LED state

//Simulate a long running process or complex task


for (int i = 0; i < 100; i++)
{
// do nothing but waste some time
delay(10);
}
}

Cul es el comportamiento del montaje y porque?


Con interrupciones: Ahora, modificando el cdigo para agregar
interrupciones.
Que efecto tiene la aplicacin de una interrupcin en el LED. El cdigo es el
siguiente:

int pbIn = 0;

// Interrupt 0 is on DIGITAL PIN 2!

int ledOut = 4;

// The output LED pin

volatile int state = LOW;

// The input state toggle

void setup()
{
// Set up the digital pin 2 to an Interrupt and Pin 4 to an Output
pinMode(ledOut, OUTPUT);

//Attach the interrupt to the input pin and monitor for ANY Change
attachInterrupt(pbIn, stateChange, CHANGE);
}

void loop()

{
//Simulate a long running process or complex task
for (int i = 0; i < 100; i++)
{
// do nothing but waste some time
delay(10);
}
}

void stateChange()
{
state = !state;
digitalWrite(ledOut, state);
}

2. OBJETIVO: MANEJO DE REGISTROS DE MANERA SECUENCIAL.


RECONOCIMIENTO DE PUERTOS Y REGISTROS ASIGNADOS A ELLOS.

PROCEDIMIENTO: SE DEBE IMPLEMENTAR EL RELOG CON LA CONDICION DE


HACER USO DE INTERRUPCIONES EXTERNAS, QUE PERMITAN RESETEAR EL
RELOG.

Se evaluara en clase la precisin del reloj y el conocimiento y manejo de los


osciladores internos del microcontrolador.

También podría gustarte