Physics 37100 Advanced Physics Laboratory I

Lab #3

(PART I:  Single measurements)

 

1)          Create a sketch to measure the light output of a PWM LED using pin 9.

a.      Use the brightest LED with corresponding series resistor from previous Lab.  Set the brightness of the LED to 128 using analogWrite. 

b.      Use the photoresistor in series with a resistor to measure the light output on A0.  It might be useful to put the LED and photoresitor into a tube to eliminate outside light.

                                                              i.      What resistance did you use? Why?

c.      Output the value of A0 to the serial port every 1/10 of a second for 10 seconds.

2)          Repeat for brightness 0, 64, and 255, and using digitalWrite HIGH in place of analogWrite.

3)          Analyze the data.

a.      Copy and paste the data from the serial monitor.

b.      Import to Matlab or other data analysis program. 

c.      Find and report the mean and standard deviation (STD) for each of the 5 brightnesses.

                                                              i.      Which has the largest STD? Why?

                                                            ii.      Is there a difference between analogWrite of 255 and digitalWrite of HIGH? Explain.

                                                          iii.      Is 128 twice as bright as 64? Explain.

 

(PART II:  Time resolved measurements)

 

4)          Modify you sketch to measure the light output of a PWM LED over time using pin 9.

a.      Create a 512 element unsigned int array Vs to hold the time series data.

b.      Acquire the data in a for loop with n running 0-511. Only use Vs[n]=analogRead(inPin) inside the loop so that we can get the data as fast as possible. 

c.      Time the loop by saving the value of micros() just before and just after the loop.

d.      After the loop output all of the array values and the time of the loop to the serial port.

e.      Do all of the work in setup() so that you do not fill up your serial monitor

5)          Analyze the data.

a.      Copy and paste the data in the serial monitor to matlab or other plotting program.

b.      Assume that each acquisition took equal time and use the total time to find the time for each point.  Is this a good assumption? Explain.

c.      Plot the data versus time for analogWrite values of 0, 128, 255, and for digitalWrite value of HIGH.  How does this help explain the data from 3c above?