Ok, it depends on which state you are in and which substance you are caught with and how much of that substance is on your person at the time of the offense. Queensland is the worst and as a youngster growing up in the 80's if you were caught with a joint you were dragged off to gaol. However most courts will slap a fine on you, or send you off to rehab or community service for small amounts of anything these days.
Anyway, what you need to do is contact your local legal service and ask them. They are quiet cool people who will help you out and point you in the right direction.
Believe me they got me out of a few sticky situations when I was younger.
Good luck