Thanks to all
This are my codes:
CODE FOR ARDUINO:
Code: Select all
Int received=0;
void loop()
{
while (received==0)
{
Serial.println(3,DEC);
delay(100);
Serial.println(1,DEC);
delay(100);
Serial.println(2,DEC);
delay(100);
Serial.println(8,DEC);
received=1;
}
}
CODE FOR PIC16F887:
Code: Select all
Int cont=0;
char dat[15];
char car[1];
int id;
void main()
{
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISB0_bit = 1; // set RB0 pin as input
TRISD = 0xF7; // Configure RD3 as output
UART1_Init(9600);
delay_ms(100);
Sound_Init(&PORTD, 3);
while (cont==0)
{if (UART1_Data_Ready()==1)
{
UART1_Read_Text(Dat, "8", 20);
cont=1;
}
}
car[0]=Dat[1];
id=atoi(car); //convert char to int
if(id==1)
{
delay_ms(100);
Sound_Play(659, 250);
delay_ms(100);
}