How do I build a machine to separate hydrogen and oxygen from water?
Depends on how much you need, but it is simple electrolysys and all you need is to fill a plastic or non-conducting tub full of salt water. Fresh water does not conduct electricity very well, then get some carbon electrodes and connect them to wires connected to a battery. You must use DC current not AC from the wall. After a while you will see bubbles on the electrodes and then they will start to rise and burst. One side will be O2 and the other will be H2. The second reference below shows how to do this as a simple science project for a school using graphite pencils for electrodes. The third reference shows how to do a small full scale plant. If you want go get fancy, then set up some solar panels to charge your batteries and run the plant in the day time, then use the batteries at night for 24/7 operations. Oh, by the way, H2 is highly explosive in gaseous state and the Oxygen produced will react with almost anything and can burst into flame.