← Advanced Instrumentation

PHYS 351 · Advanced Instrumentation

Lab 3 · LED control & timing analysis

PHYS 351 LAB 3
LED Control and Timing Analysis Using Raspberry Pi

© Ran Yang, Ph.D.
SUBMISSION   Submit the completed lab report as a PDF on Gradescope.

Due: 2:00 p.m. next Monday.

Policies and Instructions
  1. Report Format: Submit a formal, typed lab report in PDF format. Handwritten lab reports will not be accepted. Hand-drawn circuit schematics are allowed only when explicitly permitted in the task instructions. Include screenshots, code, and simulation or measurement results where specified.
  2. AI Policy: The use of any AI tool, including a large language model (LLM), to write, generate, debug, or modify code or any portion of the lab report is prohibited unless the course instructor grants explicit permission in advance. A teaching assistant (TA) cannot grant permission to use AI tools.

By signing below, I acknowledge that I have read and understood the policies and instructions above and agree to follow them.

Student Name (print):  

Student Signature:       Date:  

Preparation Tasks

  1. Setting Up Raspberry Pi:
    1. Turn on the Raspberry Pi computer.
    2. Confirm that you can see the Raspberry Pi OS desktop.
  2. Preparing Your Workspace:
    1. Open the terminal on the Raspberry Pi.
    2. Check the installed Python version.
    3. Create a new directory named “YourFirstName_python” inside /home/pi/Documents.

Basic LED Operations

  1. Blinking a Single LED:
    1. Open VS Code and create a new .py file in the directory you created.
    2. Write code to turn on one LED and save the file.
    3. Construct the circuit based on your code.
    4. Before running the code, show the circuit and code to the course instructor or a TA for approval.
  2. Alternating Between Two LEDs:
    1. Duplicate the .py file from the previous task.
    2. Modify the code to alternate between turning on a blue LED and a green LED every 2 seconds.
    3. Build the circuit and verify its timing using an oscilloscope.
    4. Record the highest frequency achieved and check for timing jitter at higher frequencies.
    5. Save oscilloscope screenshots to a USB drive and then to your computer.
TASK APPROVAL Tasks 3–4 (Basic LED Operations)

Course Instructor or TA Signature:  

Date and Time:  

Advanced LED Operations

  1. Sequential LED Lighting:
    1. Save your current program as a new copy.
    2. Modify the code to illuminate three LEDs sequentially. Use a new color, red, for the third LED.
    3. Build the circuit and test your code.
  2. RGB LED Flashing:
    1. Write a program that makes an RGB LED flash its three colors in sequence at a visible rate.
    2. Build the circuit and demonstrate its operation to the course instructor or a TA.
  3. LED Brightness Control with PWM:
    1. Write a program that changes an LED’s brightness using pulse-width modulation (PWM).
    2. Modify the duty cycle and frequency, and use an oscilloscope to monitor the output waveform.
    3. Report the waveform period and on-time in your lab report, and explain how PWM works.
    4. Evaluate whether this method provides better timing compared to previous tasks.
  4. RGB LED Breathing Effect:
    1. Write a program that makes an RGB LED “breathe” through all three colors using a pattern of your own design.
    2. Build the circuit and demonstrate its operation to the course instructor or a TA.
TASK APPROVAL Tasks 5–8 (Advanced LED Operations)

Course Instructor or TA Signature:  

Date and Time:  

Clean-Up and Data Transfer

  1. Save and Remove Work:
    1. Copy the directory you created in the first task, including all files, to your own computer.
    2. Delete this directory from the Raspberry Pi.
TASK APPROVAL Task 9 (Clean-Up and Data Transfer)

Course Instructor or TA Signature:  

Date and Time:  

Note: Always save your new programs as a new copy for each task.

Submission Reminder

  • Complete, commented Python scripts for each task.
  • Oscilloscope screenshots demonstrating the LED timing (Task 4) and the PWM waveform (Task 7).
  • The recorded maximum frequency and any timing jitter you observed.
  • An explanation of how PWM works and a comparison of its timing performance to the earlier tasks.
  • A discussion of any challenges encountered and how you overcame them.

← All course materials