rado
Member level 2
- Joined
- Feb 15, 2014
- Messages
- 42
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 293
Code C - [expand] 1 2 3 4 5 6 7 void main() { int dat; UART1_Init(9600); dat=25; delay_ms(100); UART1_Write(dat); }
Code C - [expand] 1 2 3 4 5 6 7 8 void main() { int dat; UART1_Init(9600); delay_ms(100); if(UART1_Data_Ready() ==1) dat= UART1_Read(); }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 //Tx code char uart_dat = 25; void main() { TRISA = 0xFF; TRISC = 0x80; PORTA = 0x00; PORTC = 0x00; UART1_Init(9600); Delay_ms(100); while(1) { UART1_Write(uart_dat); Delay_ms(2000); } } //Rx code sbit LED at RD0_bit; char uart_rd = 0; void main() { TRISA = 0xFF; TRISC = 0x80; TRISD = 0x00; PORTA = 0x00; PORTC = 0x00; PORTD = 0x00; UART1_Init(9600); Delay_ms(100); while(1) { if(UART1_Data_Ready() == 1) { uart_rd = UART1_Read(); if(uart_rd == 25)LED = 1; else LED = 0; uart_rd = '\0'; } } }
Code C - [expand] 1 UARTx_Write_Text("START$$");
if(UART1_Data_Ready() == 1) {
// uart_rd = UART1_Read(); this is a comment
UART1_Read_Text(uart_rd, "$$", 15);
if(uart_rd == " STOP") portb.f0=1;
else portb.f1=1;
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 //If Tx is sending 25 unsigned char uart_rd = '\0'; if(UART1_Data_Ready() == 1) { uart_rd = UART1_Read(); if(uart_rd == 25)PORTB.F0 = 1; else PORTB.F0 = 0; } //If Tx is sending "STOP" char uart_rd[]; char cmd1[] = "STOP"; if(UART1_Data_Ready() == 1) { UART1_Read_Text(uart_rd, "$$", 6); if(!strcmp(uart_rd, cmd1))PORTB.F0 = 1; else PORTB.F0 = 0; }
void main() {
int i,j,k;
TRISB =0;
TRISD =0;
TRISC =0;
PORTC =0;
if(PORTC.F5==1) goto check
else portc.f5 =1;
for(i=5;i>=0;i--)
{
PORTB =i;
for(j=9;j>0;j--)
{
PORTD =j;
delay_ms(80);
}
PORTD =0;
delay_ms(80);
}
PORTD.F6 =1;
check: PWM1_Init(1000);
PWM1_start();
PWM1_Set_Duty(125);
if (PORTB.F0==0)
{ repeat:PORTB.F4 = 1; //Run motor in clockwise
}
delay_ms(170);
PORTB.F4 = 0;
TRISB.F6 = 1;
if(PORTB.F6==1)
{
PORTB.F5 = 1; //Run motor in anti-clockwise
delay_ms(170);
PORTB.F5 = 0;
delay_ms(500);
goto repeat;
}
else PORTD.F7=1;
if(PORTD.F7 =1)
{PORTD.F6 = 0;
}
portc.f5 =0;
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?