hello everyone.I wanted to ask about the value of "4" on the analogWrite (ledPin, val / 4). what is the function of a "4" and the explanation.
complete the following code:
int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value
pinMode(ledPin, OUTPUT); // sets the pin as output
val = analogRead(analogPin);
analogWrite(ledPin, val / 4);
The code I will use as a light detection sensor with LDR and Led as the indicator, if the LDR is exposed to light and the LED will be ON if the LDR is not exposed to light then the LED will be OFF.