I am programming a dynamic C# interface to show real time states of my line follower robot sensors and motors. I am also sending a threshold of sensors to a microcontroller.
Now I want to receive the threshold value with MikroC. My code is:
char uart_rd[10];
unsigned long v;
while (UART1_Data_Ready() == 1) {
UART1_Read_Text(uart_rd, "\0", 255);
delay_ms(1000);
v = uart_rd;
UART1_Write_Text(v);
PORTD = v;
}
My C# Code to send the number is :
private void sendData()
{
Console.WriteLine("sending");
string Seuil = SeuilVal.Text;
ComPort.Write(Seuil); // Send the user's text straight out the port
Console.WriteLine(Seuil);
//SeuilVal.Clear(); //clear screen after sending data
}
When I send a number with 2 digits (99 for example) things are fine but when I send a number with 3 digits or more, I just receive two first digits (example I send 1234, but I receive 12).