The effects of Electrolysis in water and how to minimize this effect?

I remember from a long time ago, at school there was an experiment to create oxygen and hydrogen.
A piece of carbon was used, but i forgot why.
So maybe you can have a try at this:
Use pencil refill, connect your wires to that and put the pencil refill in the water.
Test it before you use it in the actual situation, to see what the pencil does.