《JavaScript》 The Simple Pendulum motion

How can we swing higher with less effort?
Theory, Predictions, and Experimental Verification with SchooMy.
Showing how fundamental physics concepts can be studied using sensors, programming, and AI, making abstract equations more concrete, interactive, and easier to understand.
Verifying the Pendulum Period Equation by Measuring the acceleration during the oscillation with SchooMy, an Accelerometer, and AI for Data Analysis.
The swing case.
Summary
A pendulum is a very simple physical system: a mass attached to a string or rod that can swing freely under the action of gravity. When the pendulum is displaced slightly from its resting position and released, it moves back and forth in a regular and repetitive way. This type of motion is called oscillatory motion, and for small angles it can be described as harmonic motion.
From theory, we know that the period of a simple pendulum depends only on the length of the pendulum and the acceleration due to gravity, and not on the mass of the object. If the oscillation angle is small (typically less than 10°), the period also remains almost constant even if the amplitude changes. This special property is known as isochronism.
In the experiment, we build a pendulum of known length and attach a SchooMy board with an accelerometer to it. The pendulum is released from a small angle, and the acceleration is recorded over time. When the data are displayed on a graph, a clear periodic pattern appears, giving a first visual indication of harmonic motion.
To support this observation, the acceleration data are analyzed using an AI system, which identifies the motion as a harmonic oscillation and rules out other types of motion such as linear or random motion. This step helps connect experimental data with physical models in a clear and intuitive way.
Finally, we use a JavaScript program written in p5.js to compute the period directly from the acceleration data and compare it with the theoretical value predicted by the pendulum formula. By repeating the experiment for different pendulum lengths, we can clearly see how the period changes and how well the experimental results agree with theory.
Theory
1. What is a Pendulum?
A pendulum is a system made of:
a mass,
attached to a string or rod,
that can swing freely under the action of gravity.
When the pendulum is displaced slightly from its resting position and released, it performs an oscillatory motion, moving back and forth in a regular way.

Examples of pendulums include:
a weight on a string,
a playground swing (for small motions),
historical pendulum clocks.
2. Key Quantities and Definitions
Length (L)
The length of the pendulum is the distance from the pivot point to the center of mass of the bob.
Amplitude
The maximum angle or displacement from the vertical.
In this experiment, we will keep the amplitude small (typically less than 10°).
Period (T)
The period is the time needed for one complete oscillation, meaning:
from one side, to the other side, and back to the starting position.
It is usually measured in seconds (s).
Frequency (f)
The frequency is the number of oscillations per second:
3. The Law of the Simple Pendulum
For small oscillations, the period of a simple pendulum is given by:
where:
T = period (seconds),
L = pendulum length (meters),
g = acceleration due to gravity (≈ 9.81 m/s²).
4. What This Formula Tells Us
1️⃣ The period depends on the length
A longer pendulum swings more slowly.
A shorter pendulum swings more quickly.
2️⃣ The period does NOT depend on the mass
A heavy bob and a light bob have the same period, if the length is the same.
3️⃣ The period does NOT depend on amplitude (for small angles)
As long as the swing angle is small, the period remains approximately constant.
This surprising property is called isochronism
5. Why Small Angles Matter
The formula above is valid only when:
the angle is small (< 10°),
the motion is smooth,
air resistance and friction are small.
For larger angles:
the motion becomes more complex,
the period increases slightly,
the simple formula is no longer exact.
6. Role of Acceleration in the Motion
During its motion, the pendulum experiences:
maximum acceleration at the ends of the swing,
maximum speed at the lowest point.
An accelerometer mounted on the pendulum can measure:
acceleration changes during the oscillation,
periodic acceleration patterns,
precise timing of each oscillation.
This allows us to measure the period very accurately.
Experimental Setup and AI Data Analysis
What to do
Build a pendulum of known length L
Attach a SchooMy + Accelerometer sensor to the rod
Start the pendulum from a small angle (< 10°)
Record acceleration data over time
Submit data to AI to identifyt the type of motion
Measuring and Testing the Frequency/Period Equation Using an Accelerometer and JavaScript Code
What to do
Use JavaScript code to compute the period and compare it with the theoretical value
Repeat the experiment for different rod lengths L
Modify the page layout and the code to compute different values
Measuring and Testing the Frequency/Period Equation Using a Magnetometer and JavaScript Code
What to do
Use JavaScript code to compute the period and compare it with the theoretical value
Repeat the experiment for different rod lengths L
Modify the page layout and the code to compute different values
カリキュラムイメージ

講師紹介
