I-Robot Guest
|
Need Help and Suggestion |
Posted: Wed May 27, 2009 4:45 pm |
|
|
Hello everyone,
I got some questions.
I am using three PICs to communicate with Bluetooth.
PIC 1 connects to PIC 2 and PIC 2 sends a number which is 30 to PIC 1 and then PIC 1 uses " Value1=getc( )" to save this value. After that, PIC 1 cuts the communication with PIC 2 and then connects to PIC 3. PIC 3 sends a number which is 60 and then PIC 1 uses "Value2=getc( )" to save the value. I want to do some comparisions between these two values.
My first question is:
Code: |
//*** PIC 1 connect to PIC 2***//
if(kbhit()) ======> connect to PIC 2 to get value
{
Value1=getc();
delay_ms(2500);
}
//*** PIC 1 connect to PIC 3 ***//
if(kbhit()) ======> connect PIC 3 to get value
{
Value2=getc();
delay_ms(2000);
}
|
The code is like this. If PIC 2 sends the same value twice to PIC 1 and when PIC 1 connects to PIC 3 and use "value2=getc", is it possible for Value2 of the PIC 3 to get the value (because of the buffer) which from PIC2?
How can I to avoid this situation? I mean that Value1 is really from PIC2 and Value 2 is really form PIC 3?
My second question is:
May I use this ==> " if (Value1>Value2+10)" to compare this to value?
I mean that I used this condition but it does not work. Did I do anything wrong?
My third question is:
I want to transmit the value ==> putc(' 30 ' ) or putc(30). Which one is correct for the real figure and which one can be used to be saved to compared.
Any help will be really appreciated.
Sincerely, |
|