JosipBros,
Sure,
You do this with a shift register, this is typically a parallel in and serial out register, and of course you can do the same in the other direction.
First some assumptions :
This is only provide you the process code for the shift register.
This is for parallel to serial...