I have an idea for a different purpose. The invention that already exists has another purpose. Mine would serve as another idea for another purpose.
Your question is a bit ambiguous. Regardless, I'm going to try to answer. Lets say someone patents the use of a laser to detect cell types. If your invention is the use of a laser to transmit data, then you are non-infringing on the laser to detect cell type patent despite using a laser. However, the laser itself might be patented and if that patent is still in force you would need to obtain a license to practice your invention. You could potentially get a patent on your invention, but there is always the potential for other relevant patents.
Since you can't describe your invention without putting it's patentability at risk, there is no way people on this site can tell you if you might infringe a specific patent. As always, the best advice about patentability and freedom-to-operate is to consult with an actual patent attorney or agent.