Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //const int len = 16;
- //char ch;
- //int i absolute 0x111;
- //char *text;
- void main() {
- // first all analog pins are set to digital
- ANSEL = 0;
- ANSELH = 0;
- TRISC=0x00; // set port C as output port
- PORTC=0x00; // set all pins of port C the value of logical 0 , C7-C5 for our semaphore
- //TRISA=0x00; // set port A as output port
- PORTA=0x00; // set all pins of port A the value of logical 0
- TRISA.B3=1; //set switches to input pins
- //TRISA.B4=1;
- PORTA.B4=1; //semaphore is initially ON
- PORTA.B3=1; //semaphore is initially in day mode
- while(1){ // repeat
- if (PORTA.B4 ==0){ //semaphore is off
- PORTC.B5=0;
- PORTC.B6=0;
- PORTC.B7=0;
- }
- else { //semaphore is on
- while(PORTA.B3 ==1 && PORTA.B4 == 1) { // while in day mode and sem. is on
- PORTC.B7=1;
- Delay_ms(20);
- PORTC.B7=0;
- PORTC.B6=1;
- Delay_ms(5);
- PORTC.B6=0;
- PORTC.B5=1;
- Delay_ms(20);
- PORTC.B5=0;
- }
- while(PORTA.B3 ==0 && PORTA.B4 == 1) { // while in night mode and sem. is on
- PORTC.B7=1;
- Delay_ms(12);
- PORTC.B7=0;
- PORTC.B6=1;
- Delay_ms(3);
- PORTC.B6=0;
- PORTC.B5=1;
- Delay_ms(12);
- PORTC.B5=0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement