Coding Challenge #159: Simple Pendulum Simulation @TheCodingTrain
Coding Challenge #159: Simple Pendulum Simulation  @TheCodingTrain
Uploaded February 2021 | Updated November 2026, 11 hours ago
Choo choo! In this challenge, I build on chapter 3 (Oscillating Motion) of the Nature of Code series and simulate a simple pendulum in p5.js via angular acceleration. thecodingtrain.com/challenges/159-simple-pendulum

πŸ•ΉοΈ p5.js Simple Pendulum editor.p5js.org/codingtrain/sketches/SN-39sHAC
πŸ•ΉοΈ p5.js OOP Pendulum: editor.p5js.org/codingtrain/sketches/lJz1cmMp4
πŸ•ΉοΈ p5.js Pendulum Array: editor.p5js.org/codingtrain/sketches/Bj82tUlIO
πŸŽ₯ Pendulum Array Exploration: youtu.be/dpqNqyQCcbY?t=2283

πŸŽ₯ Previous Coding Challenge: youtu.be/3MqJzMvHE3E?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ Next Coding Challenge: youtube.com/watch?v=Rr-5HiXquhw&list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ All Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH

πŸŽ₯ Previous Nature of Code Video: youtube.com/watch?v=okfZRl4Xw-c&list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
πŸŽ₯ Next Nature of Code Video: youtube.com/watch?v=Rr-5HiXquhw&list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
πŸŽ₯ All Nature of Code Videos: youtube.com/playlist?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM

Links discussed in this video:
πŸ”— Nature of Code Playlist: thecodingtrain.com/learning/nature-of-code/index
πŸ”— Applications of Differential Equations - The Simple Pendulum: http://calculuslab.deltacollege.edu/ODE/7-A-2/7-A-2-h.html
πŸ”— Simple Pendulum (myPhysicsLab.com): myphysicslab.com/pendulum/pendulum-en.html
πŸ”— Object Oriented Simple Pendulum (Nature of Code Book): github.com/nature-of-code/noc-examples-p5.js/tree/master/chp03_oscillation/NOC_3_10_PendulumExampleSimplified

Other videos mentioned in this video:
πŸŽ₯ Polar Coordinates - Nature of Code: youtu.be/O5wjXoFrau4
πŸŽ₯ 3.2 Angular Motion - Nature of Code: youtu.be/i2ROE_mAhU0
πŸŽ₯ Double Pendulum - Coding Challenge #93: youtu.be/uWzPe_S-RVE
πŸŽ₯ Coding Train Live! (February 6th 2021): youtu.be/dpqNqyQCcbY

Timestamps:
0:00 Choo choo!! 2021 Coding Challenge!
0:43 Code! Drawing a bob and an arm.
1:08 Explain! How are we going to think about this?
2:55 Code! Add our main variables.
3:20 Explain! How do we figure out where the bob is? Trigonometry is the answer!
4:39 Code! Use the polar coordinates formulas we just worked out.
6:30 Code! Let's use angular motion!
7:55 Explain! What is the force of the pendulum? Trigonometry is the answer!
10:46 Code! Add the pendulum force.
12:04 Whoops! Correction on why we multiply by -1.
13:34 Code! Add -1 to the formula.
13:57 Whoops! I figured out some things that I never really understood.
14:24 Code! Correct the 3 step process.
15:32 Something doesn't feel quite right.
16:59 Explain! Angular acceleration relates to the arm length!
18:58 Code! Let's divide by length.
19:54 Code! You could add some damping.
20:21 Ideas! What could you do next?

πŸš‚ Website: thecodingtrain.com
πŸ‘Ύ Share Your Creation! thecodingtrain.com/Guides/community-contribution-guide.html
🚩 Suggest Topics: github.com/CodingTrain/Rainbow-Topics
πŸ’‘ GitHub: github.com/CodingTrain
πŸ’¬ Discord: discord.gg/hPuGy2g
πŸ’– Membership: youtube.com/thecodingtrain/join
πŸ›’ Store: standard.tv/codingtrain
πŸ“š Books: amazon.com/shop/thecodingtrain
πŸ–‹οΈ Twitter: twitter.com/thecodingtrain
πŸ“Έ Instagram: instagram.com/the.coding.train

πŸŽ₯ Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ Intro to Programming: youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA

πŸ”— p5.js: p5js.org
πŸ”— p5.js Web Editor: editor.p5js.org
πŸ”— Processing: processing.org

πŸ“„ Code of Conduct: github.com/CodingTrain/Code-of-Conduct
Coding Challenge #159: Simple Pendulum SimulationAdvent of Code (Side Project Saturday!)Coding Challenge 168: MandelBulb 3D FractalIntegration Test Stream #13.4 Polar Coordinates - The Nature of CodeI, Robot5.4 Arrive Steering Behavior - The Nature of CodeCoding Challenge: 3D on Apple II2.4: random() Function - p5.js Tutorial5.1 Autonomous Steering Agents Introduction - The Nature of CodeWhere do I get my Coding Challenge ideas?!? Q&A 1.0 #shortsLets finish the tensorflow.js Autoencoder project!
The Coding Train |

Coding Challenge #159: Simple Pendulum Simulation

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER