I used a 2-axis acceleration sensor. Is located in the head it. It then measures the gravity mainly. The measured value, by the angle of rotation will change me. --- I will zero gravity measurement value measurements of the axis when the axis of the sensor was leveled to the ground ---. Position in the rotation I was divided into four regions. To detect the falling signal rising and in (up, down, left, right) the boundary position. (With a threshold detection value zero gravity fall detection circuit and rising that). I was triggered by a combination of (H, L signal using the threshold as zero gravity detection value) of H and the raw signal, L signal. Based on these signals, and to determine when to stretch or bend the leg.