|MadSci Network: Physics|
The reason that this is not perpetual motion is that, at each step of the process, the processes are not 100% efficient. That is, in order to make the hydrogen, let it rise, burn it, etc., the usable energy that you can get out of the hydrogen you made is LESS than all the energy you had to put into the operations to get the hydrogen. In real life there is always some friction or other energy-robbing process or inefficiency, so you can't get something for nothing.
Try the links in the MadSci Library for more information on Physics.