Yes logically it will work...
As you are taking the value from ADC and reading the value from the UART, after that you are comparing and accordingly the action will be taken...
that you can always put in the condition... that what you want to do when the UART value is not equals and when it is equals to...
Something like these
while(1)
{
if (position =! uart_read)
{
statement or condition as required
}
if (position == uart_read)
{
statement or condition as required
}
The below code works in only the first if condition , that is whatever the value I sent through UART , poftb.f1 is activated and print "1" in serial terminal
I am not finding any problem in logic what you have applied and i understood ur intension that wat you want exactly.
And one more thing there is no need of else if there it could be ok with else only, because either ulong<tlong or ulong>tlong.
May if possible can you monitor your both value i.e. ulong and tlong on the debugger if you have.
because i think there is some problem with your values of ulong and tlong.