can I use a public defender to file bankruptcy?
No,
Public defenders are only available for criminal cases. Foreclosures are civil.
If you call your mortgage company they many times will work to help you to get your home finances back in order. I recently was pending foreclosure, and I called the company and they helped me a lot, even reducing my payments.
If you talk to the mortgage company and they will not work with you, you may be able to find a legal aid facility within your area to help you with your problems.
It’s better to ask an experts about bankruptcy. I found this useful independent website about bankruptcy.