The dog hid under the bed whenever lightning flashed.
I’m feeling a bit uneasy about the tenses used, and their equivalence between English and Spanish.
If we’re talking about a habit, maybe “used to hide” would be clearer, and if it’s an account of events, how about “se escondió”?
Used to hide is probably a better translation.
It sounds fine to me. The word “whenever” makes it clear that it was a repeated action. If you say “used to” then it implies that the dog changed its behavior at some point, which I think exceeds to scope of the Spanish sentence. The dog could have continued that behavior up until death.
So what do you have to say about this “Durante la tormenta, el perro ladraba una vez cada vez que destelleaba un rayo”?
That sounds like it is the dog that makes the lightning flash.