const int led=5;
const int tombol1=2;
const int tombol2=3;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
pinMode (tombol1, INPUT_PULLUP);
pinMode (tombol2, INPUT_PULLUP);
Serial.begin(9600);
}
int kecerahan=0;
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(tombol1)==LOW) {
kecerahan++;
}else if (digitalRead(tombol2)==LOW) {
kecerahan--;
}
kecerahan-constrain (kecerahan, 0, 255); analogWrite(led, kecerahan);
delay(20);
Serial.println(kecerahan);
delay(500);
}