Message Boards Message Boards


An experiment in Moment of Inertia with Raspberry Pi / Arduino

Posted 5 years ago
5 Replies
15 Total Likes
Wanted to share with my kids the classical experiment on a rolling object down an incline plane using legos, arduino and Mathematica for the Raspberry Pi.

Using a window valance and some lego technic pieces we proceeded to build the inclined plane platform.

Using legos was great to allow to attach both leds and photorresistors to the inclined plane. It also allowed us to set up build a platform from where to attach a servo motor and a protractor to measure the angle of inclination.

We'll detect when the ball reaches a certain point of the platform by the the disminution of the LED light received at the photoresistors.

The adafruit web site is a very good site to explain the details on how to connect the photoresistors and leds to the Arduino.

As the readings of the photocells require of analog inputs, we decided to use a spare arduino we had at our disposal, and to have more fun, use XBEE modules to connect the arduino to the raspberry pi.

The following is the code at the Arduino.
 #include <Servo.h>
 int servoPin = 9;
 int LightSensor[4]={A1,A2,A3,A4};
 int current[4]={0,0,0,0};
 double timers[4]={0,0,0,0};
 int previous[4]={0,0,0,0};
 Servo servo; 
int i=0;
double factor=0.7;
double timer = 0;
int inByte =0;

void setup()
  for (i=0;i<4;i++){
void loop()

if (inByte==65) {
    for (i=0;i<4;i++){

void trackBall(){
int m =0;
  while (m<4){
    if (current[m]<factor*previous[m]){

Mathematica code and results to follow
 serial = DeviceOpen["Serial", {"/dev/ttyUSB0", "BaudRate" -> 19200}]
 lengths = {0., 0.175, 0.43,
    0.69} ;(*Distance between light sensors in meters*)
 data = {};(*List to capture the time between sensors*)
 ping := Module[{}, DeviceWriteBuffer[serial, {"A"}]; Pause[3];
 (*Function pings sends an "A" to the arduino to release the ball and \

collect timing*)
Button["Collect Data", data = Append[data, ping]]
Dynamic[tdata = Transpose@data;

dataPoints =

  Flatten[Table[{tdata[[i, j]], lengths[[i]]}, {i,

     Length[lengths]}, {j, Length[data]}], 1];

lm = Fit[dataPoints, {1, x, x^2}, x];

Plot[lm, {x, -0.3, 1.2},

  Epilog -> {Red, PointSize[Large], Point[dataPoints]},

  AspectRatio -> 1, PlotLabel -> lm]]
Using a hollow ball, we can work out the gravity value

Using a golf ball

A couple of videos of the experiment in action
5 Replies
This is wonderful! As a physicist I can fully appreciate fun of building such a setup. I looked through your notes and will try to help people to see a bit of physics behind the numbers. The acceleration of center of mass (CM) of a rolling body ( no-slipping ) is given by

where I is moment of inertia. For the moments of inertia in your experiment we have

  Hollow sphere               Solid ball

So now it is clear where from are the numbers 5/3 and 7/5 in your notebook. I also see that the error for golf (solid) ball is larger. I suspect due to the dimples mainly and as was suggested to me by a friend - non-uniform mass distribution. But also it is more slippery than large tenis ball - so no-slip requirement for the main formula may be a bit violated.

Excellent project!
Vitaly , Thanks for documenting the last section of the posting. Should have taken a little bit more time to do so!
The following video from Smoleny1 has a detailed explanation on the calculations for rolling objects down an inclined plane.
Hi Diego,
I'm a student in a high school in rome, I'm trying to reproduce the experiment, but I never used arduino before... can you help me? I have a problem for the electric connection, have you got some schematics? thank you very much!
Hi Francesco, hope this helps.
Posted 1 month ago

Dear Diego,

I am a teacher would like to set this experiment for my students. Could you teach me on how to connect the Xbee to Ardunio and Raspberry Pi and how ro config them?



Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract