This applet shows the motion of an object in a frictionless, airless tunnel through a uniform-density, spherical, non-rotating Earth. The sliders at top left control the start and end points of the tunnel, which are arbitrary. The "Rinitial" slider at right controls the initial displacement of the object from the centerpoint of the tunnel.
Clicking the animation button at lower left will start the object on its simple harmonic motion. It can be shown that the period of the motion is the same wherever the tunnel is located. Also, the period doesn't depend on where in the tunnel the object begins its motion (about 84 minutes round-trip); this is similar to a simple pendulum, moving through "small" angles, or an idealized spring-mass system: the period does not depend on the initial displacement.
Also shown is a satellite in an unrealistically close orbit; it has the same period of motion as the object in the tunnel. Actual spacecraft in low earth orbit are above the atmosphere, at some 200 miles or so above the surface, and their orbital period is usually about 90 minutes.
The gravitational force varies linearly with displacement from the center of the Earth (not inverse-square, as it would be outside the Earth). The definitive reference for this perhaps surprising fact is Newton's Principia, Book I, Section XII, Proposition LXXIII (Theorem XXXIII). The component of this force along the tunnel is the "restoring force" needed for simple harmonic motion.
Recall that a restoring force is (a) always directed toward the equilibrium, or rest, position of the system, and (b) is linearly proportional to the displacement from that rest position. Observe in the simulation that if the initial displacement is zero (at the center of the tunnel), the object does not move. At the center of the tunnel all the gravitational force is directed into the tunnel wall, and there is no component of that force directed along the tunnel.
The "time" slider shows the fraction of the period, zero to one (it is not in seconds). It is a good idea to reset the time to zero before starting the animation so that it will be clear from where the object begins its motion.
See most any calculus-based undergraduate physics text for the mathematical background of this simulation. Note that the plotting of the motion is done by considering the tunnel to be a rotated coordinate system with respect to the screen.