LED BRIGHTNESS ADJUSTMENT

Brighness setting LED

#include <EEPROM.h>
int pinIncrease = 2;
int pinDecrease = 3;
int pinLED = 11;
int pinSetting = 10;
int SpeedFan;
byte laju;
void setup() {
Serial.begin(9600);
pinMode(pinIncrease, INPUT);
pinMode(pinDecrease, INPUT);
pinMode(pinSetting, INPUT);
pinMode(pinLED, OUTPUT);
digitalWrite(pinIncrease, HIGH);
digitalWrite(pinDecrease, HIGH);
}
void loop() {
if(digitalRead(pinSetting) == HIGH){
laju = EEPROM.read(1);
SpeedFan = constrain(SpeedFan, 0, 255);
analogWrite(pinLED, laju);
EEPROM.write(1, SpeedFan);
laju = EEPROM.read(1);
Serial.print(laju);
Serial.print(” “);
Serial.println(SpeedFan);
delay(20); setting();
}else if(digitalRead(pinSetting) == LOW){
laju = EEPROM.read(1);
SpeedFan=laju;
analogWrite(pinLED, laju);
Serial.print(laju);
Serial.print(” “);
Serial.println(SpeedFan);
delay(20);
}
}
void setting(){
if(digitalRead(pinIncrease) == LOW){
SpeedFan++;
}else if(digitalRead(pinDecrease) == LOW){
SpeedFan–;
}
}