# Period of a Pendulum, value of 'g'

Period of oscillation of a pendulum can be measured by allowing it to intercept a beam of light falling on a photo-transistor. The LED is powered by SQR1 and the photo-transistor collector is connected to SEN, which goes to the internal analog comparator of the micro-controller. Oscillate the pendulum and measure the time period between alternate interceptions, count only for one direction.

import expeyes.eyesj, sys
p = expeyes.eyesj.open()
p.set_sqr1(0)             # set SQR1 HIGH to light LED
for k in range(10):
print p.multi_r2rtime(0,1)
# Rising edge to rising edge on comparator output, skip one edge in between

643253.0
643262.0
643251.0
643273.0
643249.0
643281.0
643245.0
643205.0
643252.0
643228.0

Acceleration due to gravity can be calculated from the period measured. Since we have used a rod pendulum, the relation

is g = 4 * pi * pi * L / (T*T) = 4*pi**2*15.4/.6432**2*2/3 = 979.7

Don't get exited with the accuracy of the result. It might have come closer to the actual value due to the error in measuring the length. What really maters is the small spread in the measured value. The frequency change due to large amplitudes can be easily observed.