Académique Documents
Professionnel Documents
Culture Documents
operando con las luces intermitentes al momento de realizar el cambio de verde a rojo, para la correcta regulacin del trfico en una esquina. Se utilizara un retardo de 5 segundos para verde y rojo, y un segundo de apagado con otro para encendido de 3 intermitencias en el verde.
ROJO RB7 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
AMBAR RB6 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
ROJO RB2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0
AMBAR RB1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
VERDE RB0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0
VALOR HEX. 24h 04h 24h 04h 24h 04h 24h 44h 81h 80h 81h 80h 81h 80h 81h 82h
DURAC5 seg. 1 seg. 1 seg. 1 seg. 1 seg. 1 seg. 1 seg. 1 seg. 5 seg. 1 seg. 1 seg. 1 seg. 1 seg. 1 seg. 1 seg. 1 seg.
Pgina 1
TRISB = 0; // PortB como salida for(;;) // bucle infinito PORTB = 0b00100100; // verde y rojo durante 5 segundos PORTB=0x24 Delay_ms(5000); // retardo de 5 segundos PORTB = 0b00000100; // nada y rojo durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b00100100; //verde y rojo durante 1 segundo Delay_ms(1000); //retardo de un segundo PORTB = 0b00000100; //nada y rojo durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b00100100; //verde y rojo durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b00000100; //nada y rojo durante 1 segundo Delay_ms(1000); //retardo de 1 segundo PORTB = 0b00100100; //verde y rojo durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b01000100; // mbar y rojo durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b10000001; // rojo y verde durante 5 segundos Delay_ms(5000); // retardo de 5 segundos PORTB = 0b10000000; // rojo y nada durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b10000001; // rojo y verde durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b10000000; // rojo y nada durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b10000001; // rojo y verde durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b10000000; // rojo y nada durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b10000001; // rojo y verde durante 1 segundo Delay_ms(1000); // retardo de 1 segundo PORTB = 0b10000010; //rojo y mbar durante un segundo Delay_ms(1000); // retardo de 1 segundo
} }
En el software MikroC se prepara el proyecto nuevo, especificando el PIC16F877A con un cristal oscilador de 4,000,000 Hz, en una carpeta, ejemplo C:\EjemMikroC
Curso de mikro C
www.oswagar.galeon.com
Pgina 2
Al momento de grabar el microcontrolador deben desplegarse las siguientes opciones( obsrvese que le asigna HS en la opcin de oscilador en el grabador PIC600 y no permite modificaciones).
Curso de mikro C
www.oswagar.galeon.com
Pgina 3
Curso de mikro C
www.oswagar.galeon.com
Pgina 4