This is my code but it doesn't work. I don't no why . I hope someone can explain the problem. Tks

unsigned char InTransfer;
char buffer;
void setup()

void loop()
  /* when get the sentences and print it*/
   while ( Serial.available())
    InTransfer=1;    // detect 
  /* After done enter one time */
  if (Serial.available()==0)
  • 1
    Can you provide more information? What doesn't work? Does it compile? What is it meant to do? – Greenonline Oct 19 '15 at 15:55

Your code works perfectly, I don't see a problem with it. It's doing exactly what you're telling it to.

The problem lies in a fundamental lack of understanding about how serial communications work on your part, so you are telling it to do the wrong thing. Until you fix that aspect no program you try and write in this way will be a success.

You should start by learning how serial communication actually works. A good starting point is an article I wrote ages ago: http://hacking.majenko.co.uk/reading-serial-on-the-arduino

| improve this answer | |
  • Can u tell me how to fix this problem ? or give me an related example because I don't understand more. Thank you – giang phuc Oct 18 '15 at 15:56
  • @giangphuc Follow the link. Read the text. – Majenko Oct 18 '15 at 15:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.