First, you need to contact several attorneys in your area and discuss the case with them and find out their retainer and payment plan options. You may be surprised to find that there are attorneys in all price ranges and your case may not necessarily need the best lawyer in town if it is your first case and there are no issues but I have no way of knowing if yo have issues though.
Keep this information relating to which attorneys you visited and their prices. If you can not afford one, take that information with you to court along with a budget. Ask the court clerk before your court date if their is an application for a public defender. Fill that out and take with you also. generally, the application will ask if you have contacted other lawyers and your financial information which is why you have prepared you budget information as well as the quotes and lawyer info.
it will be up to the judge to decide if you are eligible for a public defender. Be aware though that some judges will not appoint a PD if you have bonded out of jail. Their position is that you found the money to get out of jail, you can find the money for a lawyer. Some will easily appoint the PD's office regardless of how you got out.
If you can not afford an attorney, prepare in advance, go to court, be respectful and answer the questions concerning your finances honestly and directly. remember though, anything you say can be used against you which is why it is always better to have an attorney speak for you.