The Miranda warnings, as they're now known, came out of the Supreme Court case, Miranda v. Arizona, as an effort to protect a citizen's 5th Amendment right to remain silent. In short, the police are to alert suspects that they have the right to remain silent (and not incriminate themselves); that if they choose to speak, whatever they say can and will be used against them in proving their guilt; and that they have a right to an attorney present during questioning even if they can't afford an attorney. (Author's Note: This right should ALWAYS be exercised!) The Miranda warnings are only required to be given by police when a suspect is in custody and being questioned. (custodial interrogation). Hence, if you are not in custody or you make statements without having been questioned, then the Miranda protections do not apply. The easiest way to find out if you are in custody if you are not sure is by asking the police officer if you are free to leave. If the police do question you while you're in custody and do not read these warnings to you, then your lawyer may seek to prevent or limit the prosecutor's ability to use these statements against you. It does not mean that the charges against you are dismissed, as the prosecutor is allowed to use any other evidence against you that was lawfully obtained to try and prove their case beyond a reasonable doubt. There a great many legal decisions discussing the nuances of this area of law so I highly recommend discussing the particular facts of your case, with an experienced criminal defense attorney like myself.
Criminal Defense Attorney