Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int aa=0;
- int bb=0;
- int cc=0;
- int dd=0;
- int ee=0;
- char uart_rd;
- void main()
- {
- trisc.f0=1;
- trisc.f1=1;
- trisc.f2=1;
- trisc.f3=1;
- trisc.f4=1;
- trisc.f5=1;
- trisc.f6=1;
- trisc.f7=1;
- trisb=0b00001111;
- trisd=0b01111;
- trise=0;
- adcon1=0b0111;
- trisa=0;
- portb=0;
- portc=0;
- portd=0;
- porte=0;
- porta=0;
- UART1_Init(9600); // Initialize UART module at 9600 bps
- Delay_ms(100); // Wait for UART module to stabilize
- UART1_Write_Text("Start");
- while(1)
- {
- if (UART1_Data_Ready())
- {
- uart_rd = UART1_Read();
- if( uart_rd=='a')
- portb.f4=1;
- if( uart_rd=='A')
- portb.f4=0;
- if( uart_rd=='b')
- portb.f5=1;
- if( uart_rd=='B')
- portb.f5=0;
- if( uart_rd=='c')
- portb.f6=1;
- if( uart_rd=='C')
- portb.f6=0;
- if( uart_rd=='d')
- portb.f7=1;
- if( uart_rd=='D')
- portb.f7=0;
- if( uart_rd=='z')
- {
- portd.f5=1;
- delay_ms(4000);
- portd.f5=0;
- }
- if( uart_rd=='1')
- {
- portb.f4=1;
- portb.f5=1;
- portb.f6=1;
- portb.f7=1 ;
- }
- if( uart_rd=='0')
- {
- portb.f4=0;
- portb.f5=0;
- portb.f6=0;
- portb.f7=0;
- }
- }
- if(portc.f0==1 && portc.f1==0 &&portc.f2==0 &&portc.f3==0 &&portc.f4==1 && aa==0 )
- {
- portb.f4=1;
- aa=1;
- delay_ms(500);
- }
- if(portc.f0==0 && portc.f1==1 &&portc.f2==0 &&portc.f3==0 &&portc.f4==1 && bb==0 )
- {
- portb.f5=1;
- bb=1;
- delay_ms(500);
- }
- if(portc.f0==1 && portc.f1==1 &&portc.f2==0 &&portc.f3==0 &&portc.f4==1 && cc==0 )
- {
- portb.f6=1;
- cc=1;
- delay_ms(500);
- }
- if(portc.f0==0 && portc.f1==0&& portc.f2==1 &&portc.f3==0 &&portc.f4==1 && dd==0 )
- {
- portb.f7=1;
- dd=1;
- delay_ms(500);
- }
- if(portc.f0==1 && portc.f1==0 &&portc.f2==0 &&portc.f3==0 &&portc.f4==1 && aa==1 )
- {
- portb.f4=0;
- aa=0;
- delay_ms(500);
- }
- if(portc.f0==0 && portc.f1==1 &&portc.f2==0 &&portc.f3==0 &&portc.f4==1 && bb==1 )
- {
- portb.f5=0;
- bb=0;
- delay_ms(500);
- }
- if(portc.f0==1 && portc.f1==1 &&portc.f2==0 &&portc.f3==0 &&portc.f4==1 && cc==1 )
- {
- portb.f6=0;
- cc=0;
- delay_ms(500);
- }
- if(portc.f0==0 && portc.f1==0&& portc.f2==1 &&portc.f3==0 &&portc.f4==1 && dd==1 )
- {
- portb.f7=0;
- dd=0;
- delay_ms(500);
- }
- if( portc.f0==0 && portc.f1==0&& portc.f2==1 &&portc.f3==1 &&portc.f4==1 )
- {
- portb.f4=1;
- portb.f5=1;
- portb.f6=1;
- portb.f7=1;
- delay_ms(500);
- }
- if( portc.f0==1 && portc.f1==1&& portc.f2==0 &&portc.f3==1 &&portc.f4==1 )
- {
- portb=0b0000;
- delay_ms(500);
- }
- if(portb.f0==1 && portb.f1==0&& portb.f2==0 &&portb.f3==0 && aa==0 )
- {
- portb.f4=1;
- aa=1;
- delay_ms(500);
- }
- if(portb.f0==0 && portb.f1==1&& portb.f2==0 &&portb.f3==0 && bb==0 )
- {
- portb.f5=1;
- bb=1;
- delay_ms(500);
- }
- if(portb.f0==1 && portb.f1==1&& portb.f2==0 &&portb.f3==0&& cc==0 )
- {
- portb.f6=1;
- cc=1;
- delay_ms(500);
- }
- if(portb.f0==0&& portb.f1==0&& portb.f2==1 &&portb.f3==0 && dd==0 )
- {
- portb.f7=1;
- dd=1;
- delay_ms(500);
- }
- if(portb.f0==1 && portb.f1==0&& portb.f2==1 &&portb.f3==0 && aa==1 )
- {
- portb.f4=0;
- aa=0;
- delay_ms(500);
- }
- if(portb.f0==0&& portb.f1==1&& portb.f2==1 &&portb.f3==0 && bb==1 )
- {
- portb.f5=0;
- bb=0;
- delay_ms(500);
- }
- if(portb.f0==1&& portb.f1==1&& portb.f2==1 &&portb.f3==0 && cc==1 )
- {
- portb.f6=0;
- cc=0;
- delay_ms(500);
- }
- if( portb.f0==0&& portb.f1==0&& portb.f2==0 &&portb.f3==1 && dd==1 )
- {
- portb.f7=0;
- dd=0;
- delay_ms(500);
- }
- if(portc.f0==0 && portc.f1==1 &&portc.f2==0 &&portc.f3==1 &&portc.f4==1 || portb.f0==0&& portb.f1==1&& portb.f2==0 &&portb.f3==1 )
- {
- portd.f5=1;
- delay_ms(4000);
- portd.f5=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement