I know ChrisBFRPKY hates examples of how the Law actually works and proves him wrong, but here we go for those that aren't wearing blinders.
John is a thief and one night breaks into a house belonging to Charlie. While he is there, he sees Bob arrive and get in an argument with Charlie, which leads to Bob drawing a gun and shooting and killing Charlie.
Later the Police pick up John as a witness.
What are John's rights?
He has no right to have Miranda read to him because he is a witness, not a suspect. Should that change, the police need to read him Miranda as soon as they suspect him.
He can just refuse the interview.
He does have the right to not be questioned without a Lawyer, or to clearly state that he will no longer answer questions without a Lawyer. As a witness he will be required to provide his own Lawyer.
He has the right to leave the Interview at any point.
Once he has a Lawyer, the lawyer can answer questions for him, and advice him which to answer and which to not do so, most likely questions about the reason he was there.
Later on Bob is arrested for the murder.
What are Bob's Rights?
Before he is questioned, Bob must be read Miranda, because he is a suspect. This does not have to occur at the time of arrest, but does have to happen prior to any questioning.
Like John, Bob has the right to not answer questions without a Lawyer, however he does not have to provide one himself, he can use a public defender, or if he is lucky, have a lawyer assigned to him as part of their pro bono work (the former is more likely).
Bob cannot leave the interview whenever he likes.
Like John, once Bob has a Lawyer, the lawyer can answer questions for him, and advice him which to answer and which to not do so.
Eventually the Trial arrives and John is subpoenaed as a witness. (Note that this is the same for both a Trial and a Grand Jury Summons.)
John must appear at the court ready to testify.
During the trial John is called to the stand and placed under oath.
John has the right to plead the 5th to any question that would reveal why he was there, since this was a criminal act and thus he would incriminate himself.
John does not have the right to refuse to answer any questions that would not reveal his purpose for being there. Doing so could end up with him being held in contempt of court, resulting in a fine or even jail time.
His pleading the 5th to any question will not end his testifying, and he can only leave when allowed to stand down by the Judge. Unless the questioning goes on for some time requiring breaks, this will be after questioning by the side that subpoenaed him, followed by cross-examination by the other side, and finally the possibility of re-direct by the initial side. (Note: in the case of a Grand Jury, the Prosecutor will ask questions followed by possible questions from the Jury members. The Defense is not present.)
Bob on the other hand cannot be compelled to take the stand in his own defense should he not wish too. (And in the case of a Grand Jury, it is unlikely that he will even appear, though he can choose too)
Should Bob take the stand, he may, if he wishes, plead the 5th to any question that would incriminate him.
Just as with John, pleading the 5th to any question will not end his testifying, and he can only to return the dock/defense table when allowed to stand down by the Judge.
Hopefully this helps people that are confused by certain poster's BS and anti-legal claims about the real uses of the 5th and Miranda, and how you can act when a witness or a suspect/defendant.