pwm waves turned into flat signal

from what i know, the pwm on the arduino has some kind of waves, and i think it is affecting the button pad i'm working on. if i for example put a large capacitor before connecting the pwm to the light, will it be a clear signal, without the crazy waves?

Should put a resistor in series between the pin and the capacitor or you'll blow the output of your arduino (the capacitor is seen as a short circuit and the ATmega don't like this very much)

You shouldn't get any PWM signals from an output unless you specifically ask for it by doing an analogue write to that pin.

So for buttons you don't need to do this as they are inputs anyway.