LED Analog with 2 Buttons

I have recently been introduced to Arduino and have only been working with it for a few weeks. I worked with coding that changed the brightness on an LED with the click of a pushbutton. I now want to add a second button so that one will increase the brightness and the other will decrease it. When the increase button is pressed when after it reaches 255, I want it to just stay at full brightness, and the same for the decrease button at 0. I am having difficulty defining the variables within the code so that each button does its specific job. I appreciate any help.

Show us your sketch.

Unfortunately I am not at home and can't post my exact sketch, but attached is the code I originally used. I mainly want to alter it to add another switchpin where ledLevel = ledLevel - 51
Arduino Tutorials
Episode 3
Switch4 Program (pwm)
Written by: Jeremy Blum

int switchPin = 8;
int ledPin = 11;
boolean lastButton = LOW;
boolean currentButton = LOW;
int ledLevel = 0;

void setup()
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);

boolean debounce(boolean last)
boolean current = digitalRead(switchPin);
if (last != current)
current = digitalRead(switchPin);
return current;

void loop()
currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
ledLevel = ledLevel + 51;
lastButton = currentButton;

if (ledLevel > 255) ledLevel = 0;
analogWrite(ledPin, ledLevel);


How to use this forum

Read this before posting a programming question

Code tags.

Unfortunately I am not at home and can't post my exact sketch

When have access to your sketch show us it.