close  all;
length_take = length(arduino1_time);
FFT_data = fft(arduino1_values(1:length_take,1));
figure(11)
plot(abs(FFT_data))
FFT_data(5:end)=0;
sinal_filtrado = real(ifft(FFT_data));
fase = pi*(-5)/180;
% sinal_filtrado = arduino1_values(1:length_take,1) - 0.3*sin(2*pi*8*arduino1_time(1:length_take)+fase);
figure(1)

mov_size  = 200;

sinal_extended = [arduino1_values(1,1)*ones(mov_size,1); arduino1_values(1:length_take,1); arduino1_values(1,1)*ones(mov_size,1)];
sinal_filtrado = 0;


for shiftsign = 1:mov_size
    sinal_filtrado = sinal_filtrado + sinal_extended(shiftsign:end+shiftsign-mov_size)/mov_size;
end

sinal_filtrado = sinal_filtrado(mov_size+2:end); 

plot(arduino1_time(1:length_take), arduino1_values(1:length_take,1))
hold on
plot(arduino1_time(1:length_take), sinal_filtrado,'r','LineWidth',1)
grid on