That is ridiculous. You don't sit with your hand up for 15 minutes (He probably wasn't even looking) if you don't understand the work. Go up to his desk and ask him if he can help you, not get smart when he actually does come over to help you.
He was mad because you could've gotten his attention, but instead chose to sit with your hand up while he wasn't looking for 15 minutes. Shyness doesn't prevent you from asking your teacher a question, and if it does, you need to fix it. I'm shy sometimes as well, but I know what I need to get done and how to do it.