Arduino losing serial data.

Hello, i've been trying to get data into the arduino via serial monitor, but it seems that the arduino looses the data after a number of loops.

The code looks something like

void loop ()
{
    if(Serial.available();){
    val=Serial.read()-'0';
    display(val);
}

My display shows the number sent thru serial terminal for about 3 seconds and then the variable is lost.

I think it's got to do with the Watchdog timer. I've tried using the wdt.h library and tried resetting it or even disabling it with no success.

did you try to pu a small delay in the loop ? like delay(10);

My display shows the number sent thru serial terminal for about 3 seconds and then the variable is lost.

Can you post the actual code? The code you posted should work fine (apart from the obvious typo), but as I have no clue of how the rest of the code looks it's hard to locate the error :slight_smile:

hmm, misplaced semicolon and bracket missing.

void loop ()
{
if(Serial.available())
{
val=Serial.read()-'0';
display(val);
}
}

just my guess.