Serial.println not working

teensy3056

Active member
When I try to use Serial.println in an .ino file, I get this error.

Screenshot 2022-03-21 125039.png

I am using Visual Micro within Visual Studio 2019.

I can replace it with .printf which takes time when the downloaded code has a lot of .println in it.
 
This definitely does work in Arduino, so perhaps this would be best to ask on Visual Micro's forum?

But one quick question. Does the code compile and upload and run successfully? In other words, is this an actual compile error, or Visual Studio & Visual Micro just incorrectly red underlining "println" with their real-time analysis of the code?
 
Seems something not right with the build setup to see that.

Does this work: Serial.print( "\nBegin Setup" );

Seeing more of the code might help show why the system is confused.

Assuming all else works to build and upload for the proper selected Teensy?

.printf() does bring in more code - but not usually an issue with speed of Teensy uploading.
 
Since VisualMicro takes over the Arduino IDE, try running the code under Arduino.
If it works there then there is a settings problem with VisualMicro.
I use it (VisualMicro) all the time and I can confirm that it does work.
If your code does work with Arduino then take a screen dump (picture) of your screen showing the VisualMicro/Visual Studio settings.
PS
I am surprised that you have not upgraded to VisualStudio 2022 with it's associated version of VisualMicro.
EDIT:
Let us know the outcome so others with the same problem can find a solution.
 
Last edited:
This definitely does work in Arduino, so perhaps this would be best to ask on Visual Micro's forum?

But one quick question. Does the code compile and upload and run successfully? In other words, is this an actual compile error, or Visual Studio & Visual Micro just incorrectly red underlining "println" with their real-time analysis of the code?

println also works for me in the Arduino IDE.

The code with println in it does seem to compile, even with the red underline. However, none output from any print commands, viz., print, println, printf, would produce output in the Serial Monitor.

I wrote a basic program to try and diagnose the problem, and again, no print command would work. The program contained code to flash the LED, and that worked. So, whatever the problem, it appears that the compiler just skips over all the
Code:
Serial.
statement.

I then ran an older program which had sent output to the Serial Monitor and that worked.

Then, when I reloaded the basic program, replaced the println with printf, and it displayed in the Serial monitor.

I cannot say I have a handle on what is going on, but I am suspicious that println, when the argument is a
Code:
const char[]
, is causing some problem.

The Visual Micro forum has been unreachable for about 24 hours. Via email I was told it was back up, but I still cannot get to it.

That is what I know or suspect so far.
 
but I am suspicious that println, when the argument is a const char[], is causing some problem.

Please compose a small program which demonstrates this problem. Before posting, verify that your program is complete, so anyone can copy it into the Arduino IDE and upload to Teensy and open the Arduino Serial Monitor to observe the problem.
 
Would you please take a print screen of your Visual Micro / Visual Studio set up. I am not at my pc at the moment so cannot show you mine. Sometimes there can be problems selecting the correct way to output from the screen. I suspect that you have one of the settings wrong. Do a screen dump and I am sure we can solve your problem. I won't be back at my pc before tomorrow morning UK time.
 
Ok, I gave in. Settings below will give a good printout.
vmgood.jpg
The settings below may give problems printing out. It depends whether it compile when set to a COM? port or Teensy port. I have circled the settings which may need looking at.
vmbad.jpg
 
Would you please take a print screen of your Visual Micro / Visual Studio set up. I am not at my pc at the moment so cannot show you mine. Sometimes there can be problems selecting the correct way to output from the screen. I suspect that you have one of the settings wrong. Do a screen dump and I am sure we can solve your problem. I won't be back at my pc before tomorrow morning UK time.

BriComp,

Is this,

Screenshot 2022-03-23 125916.png

what you are requesting? If not, let me know what else you would like.
 
This code now works when it did not originally.

Code:
/*
	Name:       Teensy_Test_01.ino
*/


uint8_t out = 0;

void setup()
{
	Serial.begin(9600);
	//delay(1000);

	while (!Serial) {
		// wait for serial port to connect. Needed for native USB
	}

	Serial.println("Ready");
	//Serial.printf("%s\n", "Ready");

	pinMode(13, OUTPUT);

}

void loop()
{
	digitalWrite(13, out);

	if (out) {
		out = 0;
	}
	else {
		out = 1;
	}

	Serial.print("LED is ");
	//Serial.printf("%s", "LED is ");
	Serial.println(out);
	//Serial.printf("%u\n", out);
	delay(500);

}

Both the println() in setup() and print() in loop() are underlined presumably by Intellisense,

Error message.png

Something clearly changed, probably by me.

For what it is worth, my computer has been sending the Windows 10 C:\Windows\Media\Windows Hardware Remove.wav to the speaker. I had previously found that I would get that sound when something in my Teensy program was not right. For example, when I was working on the TPM1 timer / counter, not disabling it before attempting to make register changes would result in that sound. It makes the sound twice before the above program opens the Serial Monitor window.

When I replace the "questionable" print lines with printf() line, that sound is also generated twice, but there is no Intellisense underline.

I am using Visual Studio 201916.11.11 and Visual Micro 2022.218.1901.
 
BriComp,

Is this,

View attachment 27887

what you are requesting? If not, let me know what else you would like.

Yes as you can see you have the USB port set to usb:0/4.... and now it is working. I have found this to be the best settings for getting the serial (usb) monitor to work.
Watch out it can switch back to COM? (whatever port your teensy is) seemingly all by itself. I think it's when windows thinks it's found a new/correct device.
 
Thanks for the update. Support for teensy virtual usb ports was added to Visual Micro a few years ago. This is an old post but still a useful post :)
 
Back
Top