Make an LED less bright As an exercise to learn rather then the most efficient way to accomplish a goal.... (i'm a hands on hardware guy, but I need to get my Sh!T together and learn some coding)
I would like to make an LED less bright within a project.  I have a nano set up to control a relay to control a dc load when a momentary switch is pressed (this is kinda needlessly complicated solely to allow me to use a particular momentary switch I wanted to use for a bunch of not that great reasons ;-)
Anyway... the code i'm using is this:
int pbuttonPin = 2;// connect output to push button
int relayPin = 10;// Connected to relay (LED)

int val = 0; // push value from pin 2
int lightON = 0;//light status
int pushed = 0;//push status


void setup() {
  // Robojax.com code and video tutorial for push button ON and OFF
  Serial.begin(9600);
  pinMode(pbuttonPin, INPUT_PULLUP); 
  pinMode(relayPin, OUTPUT);
 digitalWrite(relayPin, HIGH);// keep the load OFF at the begining. If you wanted to be ON, change the HIGH to LOW
}

void loop() {
// Robojax.com code and video tutorial for push button ON and OFF
  val = digitalRead(pbuttonPin);// read the push button value

  if(val == HIGH &amp;&amp; lightON == LOW){

    pushed = 1-pushed;
    delay(100);
  }    

  lightON = val;

      if(pushed == HIGH){
        Serial.println(&quot;Light ON&quot;);
        digitalWrite(relayPin, LOW); 
       
      }else{
        Serial.println(&quot;Light OFF&quot;);
        digitalWrite(relayPin, HIGH);
   
      }     

// Robojax.com code and video tutorial for push button ON and OFF

  delay(100);

The above code is straight up cut and paste... i'm clueless
I have a LED cathode on pin 10, (so i know the relay is on more easily from a distance).  however the application is on a boat, and at night it is too bright and distracting.  So i want to make the LED dimmer... I know I could add a larger value resistor, but i want to expand my understanding and would like suggestions on other ways PWM maybe....
cheers:
There are two methods of dimming a LED : by PWM or by a limiting current resistor.

PWM code
 `//Initializing LED Pin
 int led_pin = 10;
 void setup() {
 //Declaring LED pin as output
         pinMode(led_pin, OUTPUT);
 }
 void loop() {
         analogWrite(led_pin, 127); // half intensity
         delay(5);
 }`


Hardware. Use following schematic