Serial Monitor Issues

Hello

I am beginning a project that requires me to know the value of voltage running through the circuit based on the potentiometer value. I am new to Arduino and I have realized with some tests that when I use the Serial.println command the LED in the circuit stays on no matter if the potentiometer is fully open or closed (it does dim and brighten but is never fully off, but when I remove the Serial command it does turn off and dim fine based off of the value of the potentiometer.

Why is it that the serial command seems to keep the circuit open. How can i fix this?

My circuit is setup exactly as shown here Arduino | Control LED brightness with potentiometer | Fade (with code e schematic) - YouTube . Only difference in code is I enable Serial and print the "knobvalue" not shown in the original code.

Thanks

maybe a photo of your circuit would help...

Can you please paste here the code? (use the "code" tag of the tool bar)

EDIT: Nevermind, the code is so easy that is not necessary. The code should look like this:

int knobvalue;
int potpin = 0;

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

void loop()
{
  knobvalue = analogRead(potpin);
  knobvalue = map(knobvalue, 0, 1023, 0, 255);
  analogWrite(11, knobvalue);

  Serial.println(knobvalue);
  delay(1000);
}

BTW, the function map() is not necessary if you don't want to write the value back to the LED.

Hello
Thank you for your reply. I may not have been very clear but the issue I am having is that when I include the serial command in the code the LED stays on even when the potentiometer is fully resisting. I was wondering why the serial command seems to keep the circuit open.

We can't tell you why your code is not working if we can't see your code.
The code posted by luisilva contains Serial output and works, therefore it can be done, therefore they way YOU did it is causing issues, and therefore YOU need to post YOUR code if you want comments on why YOUR code does not work.

Help us to help you.

I have another question. I read another time what you write the first post, and for what I understand your complain is that the LED don't completely turn off when you're using the serial communication (and the potentiometer is completely off). What are the value that you read in the serial monitor at that time? Zero or other value? All the system can be working fine, but you don't have the potentiometer "telling you" the right value.

Which pin is the pot wired to and how ?
I have a sneaking suspicion that you have it wired to pin 0 instead of pin A0

UKHeliBob:
Which pin is the pot wired to and how ?
I have a sneaking suspicion that you have it wired to pin 0 instead of pin A0

Or maybe the led is wired to pin 1 because it is closer to the led than pin 11?
Then when serial begins, TX goes high except when it transmits a 1 bit.

Until you post your code and a diagram/photo of your circuit (not the one's you copied,
since you have undoubtedly copied them wrong), we are only guessing.

The reason we ask for circuit and code is to fix your problem from a position
of knowledge, not guesswork!