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.
Preparation Tasks
- Setting Up Raspberry Pi:
- Turn on the Raspberry Pi computer.
- Confirm that you can see the Raspberry Pi OS desktop.
- Preparing Your Workspace:
- Open the terminal on the Raspberry Pi.
- Check the installed Python version.
- Create a new directory named “
YourFirstName_python” inside/home/pi/Documents.
Basic LED Operations
- Blinking a Single LED:
- Open VS Code and create a new
.pyfile in the directory you created. - Write code to turn on one LED and save the file.
- Construct the circuit based on your code.
- Before running the code, show the circuit and code to the course instructor or a TA for approval.
- Open VS Code and create a new
- Alternating Between Two LEDs:
- Duplicate the
.pyfile from the previous task. - Modify the code to alternate between turning on a blue LED and a green LED every 2 seconds.
- Build the circuit and verify its timing using an oscilloscope.
- Record the highest frequency achieved and check for timing jitter at higher frequencies.
- Save oscilloscope screenshots to a USB drive and then to your computer.
- Duplicate the
TASK APPROVAL
Tasks 3–4 (Basic LED Operations)
Course Instructor or TA Signature:
Date and Time:
Advanced LED Operations
- Sequential LED Lighting:
- Save your current program as a new copy.
- Modify the code to illuminate three LEDs sequentially. Use a new color, red, for the third LED.
- Build the circuit and test your code.
- RGB LED Flashing:
- Write a program that makes an RGB LED flash its three colors in sequence at a visible rate.
- Build the circuit and demonstrate its operation to the course instructor or a TA.
- LED Brightness Control with PWM:
- Write a program that changes an LED’s brightness using pulse-width modulation (PWM).
- Modify the duty cycle and frequency, and use an oscilloscope to monitor the output waveform.
- Report the waveform period and on-time in your lab report, and explain how PWM works.
- Evaluate whether this method provides better timing compared to previous tasks.
- RGB LED Breathing Effect:
- Write a program that makes an RGB LED “breathe” through all three colors using a pattern of your own design.
- 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
- Save and Remove Work:
- Copy the directory you created in the first task, including all files, to your own computer.
- 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.