Professional Documents
Culture Documents
MEXICO
INSTITUTO TECNOLÓGICO DE
QUERÉTARO
Carrera:
Ingeniería electrónica
Materia:
Microcontroladores
Tema:
Programa de semáforo
Profesor:
Ing. Gustavo Ontiveros Rodríguez
Integrantes:
Fernández Ávila Alejandro
Espino Larios José Ricardo
Mendoza Sánchez Eduardo Tomás
Mañón Moya Juan Diego
Fecha:25/07/19
Grupo:3A
#include <16f887.h>
#fuses XT, NOWDT, NOPROTECT
#use delay (clock=4000000)
#byte portb=0x06
#byte trisb=0x86
int a;
int aux;
void main()
{
aux=0;
set_tris_A(0b11111111);
set_tris_B(0xF0);
portb=0x00;
while(true)
{
delay_ms(1);
if(input(PIN_A0)==1)
{
do{ } while(input(PIN_A0)==1);
aux=aux+1;
}
if(aux==1)
{
do
{
output_high(PIN_B5); // Enciende LED
output_high(PIN_B0); // Enciende LED
delay_ms(4000);
output_low(PIN_B5);
for(a=1;a<=4;a++)
{
delay_ms(250);
output_high(PIN_B5);
delay_ms(250);
output_low(PIN_B5);
}
output_high(PIN_B4); // Enciende LED
delay_ms(4000); // Retardo de 2 segundos. Semaforo Amarillo
output_low(PIN_B4); // Apaga LED
while(true);
}
// secuencia dos
delay_ms(1);
if(input(PIN_A1)==1)
{
do{ } while(input(PIN_A1)==1);
aux=aux+1;
}
if(aux==1)
{
do
{
output_high(PIN_B2); // Enciende LED
output_high(PIN_B3); // Enciende LED
delay_ms(4000);
output_low(PIN_B2);
for(a=1;a<=4;a++)
{
delay_ms(250);
output_high(PIN_B2);
delay_ms(250);
output_low(PIN_B2);
}
output_high(PIN_B1); // Enciende LED
delay_ms(4000); // Retardo de 2 segundos. Semaforo Amarillo
output_low(PIN_B1); // Apaga LED
//
output_high(PIN_B5); // Enciende LED
output_high(PIN_B0); // Enciende LED
output_low(PIN_B3);
delay_ms(4000); // Retardo de 6 segundos. Semaforo de 4 Ote
output_low(PIN_B5); //////////////////////
{
for(a=1;a<=4;a++)
{
delay_ms(250);
output_high(PIN_B5);
delay_ms(250);
output_low(PIN_B5);
} //////////////////
output_high(PIN_B4);
delay_ms(5000);
output_low(PIN_B4);
output_low(PIN_B0);
}
}//
while(true);
}
}
12