Pendulum: a physics lab in your browser
Build a pendulum model with sliders for length, angle and mass, a choice of Earth, Moon or Jupiter, and a swing graph. One prompt in Gemini.

✓ Prompt tested in Gemini (signed out): worked 3 out of 3 times
- Level
- Intermediate
- You make
- A pendulum model in a single HTML file
- Age
- 11+
- Time
- ≈ 30 min
- Tools
- Gemini
- Account
- Not needed
What you’ll get
The pendulum swings for real, a trail follows the weight, and a graph of the angle is drawn below. Change the length, angle, mass and planet — and watch how the period changes. Press “Play the example” above — Gemini made it from the prompt below.
Steps
-
Open gemini.google.com. Under 13 — together with a parent, on their device.
-
Copy the whole prompt and send it:
Make a pendulum model in a single HTML file. Don't load anything from the internet: no Tailwind, no CDN, no fonts, no images and no libraries — only your own CSS and JavaScript inside the file. Don't save anything in the browser's memory. Draw on a canvas a pendulum that swings for real (don't use the small-angle approximation). Sliders: string length from 0.2 to 2 m, starting angle from 5° to 80°, mass of the weight. A planet switch: Earth, Moon, Jupiter. Show the measured swing period and, next to it, the formula T = 2π√(L/g). A trail follows the weight, and below it a graph of angle versus time is drawn. "Pause" and "Restart" buttons. Everything should look good on a phone. Show the result in Canvas. -
Wait about a minute, click Preview and try all the buttons and sliders.
-
Check the AI (see the question above).
-
Click Download (sometimes it’s under the Export menu) — the file opens in any browser. Show it in class!
Change the prompt
Before sending, swap a few words and you get your own version. Change only the words, and leave the rules about the internet and Canvas as they are.
- “Earth, Moon, Jupiter” → “Earth, Mars, Pluto”
- “from 0.2 to 2 m” → “from 0.1 to 5 m”
If it doesn’t work
- The AI says it changed everything, but the result is the same? Write:
Nothing changed. Show the updated version in Canvas. - No Preview button? Write:
Show the result in Canvas. - The pendulum froze? Write: “The pendulum doesn’t swing after I press Restart. Fix it, change nothing else.”
Sending work to the gallery opens soon.