For anyone who likes to have a reference code, check out here. All credits goes to the original creator. I do not own any part of it.
“The code controls the servo and assumes there will be two legs on each one. So, I would suggest having an even number of legs. Getting the timing right will take experimentation. Good luck.” – Richard Stones
“…the books where I found the project is ISBN:978-1-449-38971-0 Make: Arduion Bots and Gadgets by O’Reilly by Kimmo Karvinen and Tero Karvinen.” – Richard Stones