const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int ledPin = 13;
void setup() {
// put your setup code here, to run once:
pinMode (buttonPin1, INPUT);
pinMode (buttonPin2, INPUT);
pinMode (ledPin, OUTPUT);
digitalWrite (buttonPin1, HIGH);
digitalWrite (buttonPin2, HIGH);
}
int ledBrightness = 128;
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead (buttonPin1) == LOW)
{
ledBrightness--;
}
else if (digitalRead (buttonPin2) == LOW)
{
ledBrightness++;
}
ledBrightness = constrain(ledBrightness,0,255);
analogWrite (ledPin, ledBrightness);
delay(1);
}