Convert a 16 bit integer to 16 discrete outputs

There is a very similar question in this post. There is an alternative solution there.