Raspberry Pi pin connections
Below we show a diagram of how the Raspberry PI is connected to the detector. We use 3 pins on the Raspberry Pi: Pin 1, 7, and 9. Pin 1 is 3.3 volts, and pin 9 is ground. We sample pin 7 to see if the laser is incident on the detector or blocked.
C program to collect the data
We use a C program to collect the data, and an HTML program to graph the results. The C program tandvel.c is used to collect the data. The GPIO pin number 7 is read using a nice GPIO interface library for C found at wiringPi (Thanks Dan for writing this nice resource). Compile the program tandvel.c by typing "gcc -lwiringPi tandvel.c". Run the code by typing "./a.out" or rename the object file when compiling by adding "-o filename". The menu will describe the different options. To collect data, type "d" then return. The clock will start when return is pressed. The time and speed data are displayed and the file data.txt is produced for graphing.
HTML program to graph and analyze the data
Once tandvel.c is run, a file called data.txt will be produced. Run the following code graphdata2.html in a browser. Upload the file data.txt, and see the data graphed. Hit the "fit it" button to see the best straight line fit and the slope plus intercept values.
Physics Department| College of Science