# low pass filter

I am new to DSP, I'm trying to implement a low pass filter in a microcontroller and I'm looking for examples on the internet.

One of the simplest low pass filter (as its title says) is this. But I don't understand how is this a low pass filter? All that I see is just an equation

y = 2x - 1


I made a simple example on google sheets and it gave me the same triangle signal with just higher amplitude. What am I missing?

The equation you probably refer to is

$$y[n]=x[n]+x[n-1]\tag{1}$$

(which is not equivalent to $$y[n]=x[n]+x[n]-1$$).

The integer $$n$$ is the time index, so from in Eq. $$(1)$$ the output is computed as the sum of the current and the previous input values. This is, up to scaling, equivalent to a two-point averaging operation. This low pass filter is really quite simple but it also doesn't really do much.

Another very simple but better low pass filter is

$$y[n]=\alpha x[n]+(1-\alpha)y[n-1]\tag{2}$$

which is called an exponentially weighted moving average filter. There are a lot of questions about that type of filter on this site, e.g. here, here, here, and here.