I have been having issues with my Leonardo. I'm trying to set up a communications channel between my Java program and my Arduino. I've done this once a couple years ago. To set up the link and make sure both ends are working, I set up a simple sketch for the arduino, where the loop() function is just if (Serial.available() >0) {Serial.write(Serial.read()); }. This should make the Arduino echo any inputs into the serial monitor. However, when I go to start the serial monitor, I am unable to select the serial port under the tools menu. Anyone have any clue what's going on?
No reset when you open the serial port.
Unlike the Arduino Uno, the Leonardo and Micro won't restart your sketch when you open a serial port on the computer. That means you won't see serial data that's already been sent to the computer by the board, including, for example, most data sent in the setup() function.
This change means that if you're using any Serial print(), println() or write() statments in your setup, they won't show up when you open the serial monitor. To work around this, you can check to see if the serial port is open after calling Serial.begin() like so:
Serial.begin(9600);
// while the serial stream is not open, do nothing:
while (!Serial) ;
Okay, so in my setup I need to put "while(!Serial)" and that will make the option in the IDE show up properly?
Okay, so in my setup I need to put "while(!Serial)" and that will make the option in the IDE show up properly?
No. Runaway Pancake's response has nothing to do with your problem. It may come in useful later.
Are you able to upload sketches to the Arduino? The Tools + Serial port menu will show a list of ports that the Arduino might be connected to. If that list is empty, the Tools + Serial port menu will not be accessible (it will be grayed out).
This suggests that you have not installed the needed drivers, or missed some other step in installing the software for the Leonardo to successfully be talked to.
Yes, I can upload sketches to the board just fine. And sometimes it's not greyed out. It's half and half. I just have no clue how to make it always clickable. I don't think it can be broken drivers, since sometimes it DOES work.