0% found this document useful (0 votes)
25 views4 pages

Tecnológico Nacional de Mexico Instituto Tecnológico de Querétaro

This document contains a program written in C for a microcontroller to control a traffic light simulation. The program uses inputs from buttons to toggle between two traffic light sequences. Each sequence turns on and off the appropriate LEDs to mimic the changing lights of a traffic light in red, yellow, and green phases with delays. When the input button is pressed, it increments a counter to change to the next sequence. The LED outputs and delays are programmed to repeat continuously for each traffic light sequence.

Uploaded by

Ale Fernandez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views4 pages

Tecnológico Nacional de Mexico Instituto Tecnológico de Querétaro

This document contains a program written in C for a microcontroller to control a traffic light simulation. The program uses inputs from buttons to toggle between two traffic light sequences. Each sequence turns on and off the appropriate LEDs to mimic the changing lights of a traffic light in red, yellow, and green phases with delays. When the input button is pressed, it increments a counter to change to the next sequence. The LED outputs and delays are programmed to repeat continuously for each traffic light sequence.

Uploaded by

Ale Fernandez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

TECNOLÓGICO NACIONAL DE

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

output_high(PIN_B3); // Enciende LED


output_high(PIN_B2); // Enciende LED
output_low(PIN_B0);
delay_ms(4000); // Retardo de 6 segundos. Semaforo de 4 Ote
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);
delay_ms(5000);
output_low(PIN_B1);
output_low(PIN_B3);
}
}

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

You might also like