Pin 13 LED glows when running sketches that do not mention Pin 13

As the subject says! i have just started Arduino and have written a few sketches based on tutorials but I notice that the L LED lights up and sometimes changes brightness but there is no mention of Pin 13 in the sketch. The sketches run fine, is there something wrong with my board?

Thanks

Steve

Please post your full sketch (the most minimal one that causes the pin 13 issue). If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it’s ok to add it as an attachment.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you’re using the Arduino Web Editor then you will not have access to this useful tool. I recommend using the standard Arduino IDE instead.

When your code requires a library that’s not included with the Arduino IDE please always post a link(using the chain links icon on the toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger(Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.

Sketch as requested:

//Variable Blinking LED

int potPin = A0;  // Declare potPin to be analog pin A0
int LEDPin = 9;   // Declare LEDPin to be arduino pin 9
int readValue;     // Use this variable to read Potentiometer
int blinkRate;      // Use this variable for writing to delay time


void setup() {
  pinMode(potPin, INPUT);     // Set potPin to be an input
  pinMode(LEDPin, OUTPUT); // Set LEDPin to be an OUTPUT
  Serial.begin(9600);            // Turn on Serial Port
}  

void loop() {
  
 readValue = analogRead(potPin);                                // Read the voltage on the Potentiometer
 blinkRate = (1-(0.99/1023.)) * (1023 - readValue);     // Calculate Blink rate
 digitalWrite(LEDPin, HIGH);
 delay(blinkRate);
 digitalWrite(LEDPin, LOW);
 delay(blinkRate);
  
}

Sorry I could not find tools/autoformat?????

No Arduino at hand to check the behaviour on my uno.

You can set pin 13 to output in setup and make it low (or high) in setup. That should stop the behaviour.

I'd guess he's using an Uno.

Looking at the schematic, I'm unsure why every uno doesn't do this when nothing is connected to pin 13 - pin13 is connected to the positive side of one of the opamps (with - tied to ground, so it's just buffering it), but when the pin is set input, it should be floating, so we'd expect the LED to be dimming and brightening randomly as the pin floated between 0v and 5v....

Maybe the tiny current through the opamp is normally enough to keep it pulled down to ground (and this is a clone that used a better opamp)?

sterretje: No Arduino at hand to check the behaviour on my uno.

You can set pin 13 to output in setup and make it low (or high) in setup. That should stop the behaviour.

Done! and it does the trick. Many thanks!