Juego de luces
// Archivo: Esquematico_PIC16F1938.c
// Autor: Jorge Fernando Reyes Suarez
// Trafico Y Señalizacion Vial
// v 1.1
// DESCRIPCION:Torreta para camionetas
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//DECLARACIÓN DE LIBRERIAS GLOBALES
#include//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//DEFINICIONES
//PALABRA DE CONFIGURACION
#pragma config FOSC=INTOSC, WDTE=OFF, PWRTE=ON, MCLRE=OFF, CP=OFF, CPD=OFF, BOREN=ON, CLKOUTEN=OFF, IESO=ON, FCMEN=ON
#pragma config WRT=OFF, PLLEN=ON, STVREN=ON, BORV=HI, LVP=OFF//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//DEFINICION DE VARIABLES
#define Led1 LATA0
#define Led2 LATA1
#define Led3 LATA2
#define Led4 LATA3
#define Led5 LATA4
#define Led6 LATA5
#define Led7 LATA6
#define B1 PORTBbits.RB0
#define B2 PORTBbits.RB1
#define B3 PORTBbits.RB2
#define B4 PORTBbits.RB3#define B5 PORTBbits.RB4
#define B6 PORTBbits.RB5
#define _XTAL_FREQ 32000000
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//DEFINICION DE LIBRERIAS ESPECIFICAS//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//PROTOTIPADO DE FUNCIONES
void InicializaSistema(void);
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//PROGRAMA PRINCIPAL
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
void main(void)
{
// Inicializa Programa
InicializaSistema();
//Ciclo Infinito
while(1)
{
if(B1==1)
{Led4=1;
Led1=0;
Led2=0;
Led3=0;
Led5=0;
Led6=0;
Led7=0;
}
if(B2==1)
{
Led4=1;
__delay_ms(70);
Led4=0;
__delay_ms(70);
Led1=0;
Led2=0;
Led3=0;
Led5=0;
Led6=0;
Led7=0;
}if(B3==1)
{
Led4=0;
Led1=1;
Led5=1;
__delay_ms(100);
Led1=0;
Led5=0;
__delay_ms(100);
Led2=1;
Led6=1;
__delay_ms(100);
Led2=0;
Led6=0;
__delay_ms(100);Led3=1;
Led7=1;
__delay_ms(100);
Led3=0;
Led7=0;
__delay_ms(100);
Led2=1;
Led6=1;
__delay_ms(100);
Led2=0;
Led6=0;
__delay_ms(100);
}
if(B4==1)
{
Led4=0;Led1=1;
Led2=1;
Led3=1;
__delay_ms(120);
Led1=0;
Led2=0;
Led3=0;
__delay_ms(120);
Led4=0;
Led5=1;
Led6=1;
Led7=1;
__delay_ms(120);
Led5=0;
Led6=0;
Led7=0;
__delay_ms(120);
}
if(B5==1)...
Regístrate para leer el documento completo.