The Sixth Amendment to the U.S. Constitution states that all persons accused of a crime have the right to counsel in their defense.
Explicitly, the Sixth Amendment states that, “In all criminal prosecutions, the accused shall enjoy the right to a speedy and public trial, by an impartial jury of the state and district wherein the crime shall have been committed, which district shall have been previously ascertained by law, and to be informed of the nature and cause of the accusation; to be confronted with the witnesses against him; to have compulsory process for obtaining witnesses in his favor, and to have the assistance of counsel for his defense.”
Over the legal history of the United States, the Supreme Court has ruled that the Sixth Amendment requires the levels of government to provide counsel to persons accused of crime who cannot afford to hire a lawyer. The right of appointing counsel applies to the federal government from the Sixth Amendment and to the state governments under the due process clause of the Fourteenth Amendment. To comply with the U.S. Supreme Courts directives, state governments have established a range of indigent defense services.
Once you're arrested and booked, your case is provided to the appropriate prosecutor's office where an independent decision is made as to what charges should be filed, if any. You have the right to a speedy trial, which usually means that the prosecutor must file any charges within 72 hours (48 hours in some states). A prosecutor is not bound by the initial charge decision and can later change the crimes charged once more evidence is obtained.
Next is your arraignment. At this point, the charges against you are read in court and you'll be asked whether you plead guilty or not guilty. You can also plead "nolo contendere" or "no contest," which aren't technically pleas, but indicate that you don't contest the charges. The plea of nolo contendere cannot be used in other aspects of the criminal trial as an admission of guilt, but can be used in the indictment phase as an implied confession of the specific offense charged and an admission of the facts in the indictment. A plea of nolo contendere is only accepted by a judge if made voluntarily and intelligently.
You may be able to get out of jail after your arrest and before trial by posting bail. During this process, you pay money to the court to ensure that you'll make future court appearances. If you do, the bail is refunded to you, but if not, the court keeps the money and can issue a warrant for your arrest.