What are the states that the landing gear can be in?
Any instruments always show only three states:


Down and locked (green)
Up/stowed (extinguished)
Anywhere in between (red)




If you want to simulate it, remember that while the pilot can only command one of the two end states, the transition is a continuous process and you need to represent exact position of the gear in each frame of the simulation. So you need a value that will smoothly transition between 0 (stowed) and 1 (down and locked). Any value in between will indicate red on the instrument, but will correspond to different state of the gear animation.

The exact steps during gear extension (and in reverse for raising) differ by aircraft, but generally the animation will have three parts that you will map to suitable ranges of the gear state value:


opening the gear door,
lowering the gear and
closing the main gear door.


The last step actually complicates issues a bit, because the gear is already down and locked when the main gear door close and in case you do gravity extension the main gear door remain open.

So the suggested mapping is actually something like:


opening the gear door 0.0 to 0.3
lowering the gear 0.4 to 1.0
closing the main gear door 1.1 to 1.4


When you extend the gear normally, the value will transition up to 1.4 (and show green past 1.0), when you extend the gear via alternate mechanism (gravity drop), it will only transition to 1.0. If you want to simulate alternate extension, of course.

Tweak the values to make the animation look appropriate. The relative speed differs by aircraft. Some aircraft also don't have gear door (e.g. 737 only has one panel that is attached to the strut on main wheels; it still does have nose gear door, so the process will be slightly different for each leg).

Which leads me to note, that if you want to simulate failures, you definitely need separate value for each leg, because some failures, like jammed actuator, only affect one gear. Also in reality the legs take slightly different time to extend, so you can add some variability to the transition time if you wish.