-1

I have an Arduino Lilypad with this simple code where I try to write a simple message to the serial console. The baud rate is set to 9600 both in the code as well as in the serial console and I'm using the FTDI UART tool. However, the output I'm receiving is corrupted and I'm not sure what could be the cause. Any ideas or suggestions are welcome. Thanks!


void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(3000);
  Serial.write("Hello World");
}

enter image description here

Arduino is connected to the FTDI tool as shown here enter image description here

11
  • @jsotola I have it connected as shown on the picture here i.stack.imgur.com/axOsO.png
    – Jozef Cipa
    Aug 20, 2023 at 19:19
  • @jsotola updated, but that doesn't really answer my question 🙂
    – Jozef Cipa
    Aug 20, 2023 at 19:55
  • 1
    Just as an experiment, try changing the code to make the serial port 4800 and if that doesn't work, try 119200. Alternatively, change the speed in the Terminal Monitor window to double or halve the speed.
    – Nick Gammon
    Aug 20, 2023 at 21:18
  • I say that because it looks like the baud rate is wrong. Don't change both settings at once.
    – Nick Gammon
    Aug 20, 2023 at 21:20
  • 1
    What we have now is just an unexplained work-around. We still need to find out the underling reason, why you need different baudrates for your Lilypad and the PC. Is it possible that the IDE thinks that the Lilypad has a 16 MHz clock? Aug 21, 2023 at 5:40

1 Answer 1

1

It looks like the wrong baud rate. That often results in garbage characters. You said in a comment that halving the baud rate on the Arduino end seemed to synchronize the baud rates, and you could see proper characters.

I'm a bit puzzled by that because you were evidently able to upload the sketch in the first place. Therefore the baud rate was correct during the uploading process.

Looking in the file boards.txt which you should find somewhere in your Arduino installation, there appear to be a number of Lilypad variants. Perhaps you inadvertently chose the wrong one in the "Board" menu in the IDE?

It looks like the correct baud rate was used for the uploading, but the code generated by the compiler (because of settings passed by the IDE) thought that the board was running at half the speed it actually was (so it set the baud rate clocks to run faster), so by reducing the baud rate in the Serial.begin they became in sync.

You could just live with the difference, or try experimenting with choosing different Lilypad board types.

If the baud rate is wrong, probably the delays will be wrong too, whether or not that matters is up to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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