Untitled
Assignment: Morse Code LED Controller with Variable Brightness
Objective
Extend a basic text-to-Morse-code converter to implement LED signaling with brightness control using a potentiometer.
Learning Outcomes
- Understanding ADC (Analog-to-Digital Conversion) configuration and usage
- Implementing PWM (Pulse Width Modulation) for LED brightness control
- Working with hardware peripherals in embedded systems
- Real-time signal processing and timing management
Hardware Requirements
- Raspberry Pi Pico
- LED (with appropriate current-limiting resistor)
- Potentiometer
- Breadboard and jumper wires
CMake Configuration
Don't forget to add appropriate libraries to CMakeLists.txt
.
Implementation Tasks
1. Hardware Configuration (25 points)
- Choose appropriate GPIO pin for LED
- Select suitable ADC input for potentiometer
- Determine appropriate PWM frequency (consider LED characteristics)
- Choose PWM wrap value based on required brightness resolution
2. ADC Configuration (25 points)
- Initialize ADC hardware for potentiometer reading
- Configure GPIO for analog input
- Implement proper value scaling from ADC (0-4095) to PWM range
3. Morse Code Functions (50 points)
- Implement display_dot() with variable brightness
- Implement display_dash() with variable brightness
- Implement display_character() with proper handling of:
- Uppercase and lowercase letters
- Spaces between words
- Invalid characters
- Ensure proper timing ratios between symbols
- Read potentiometer value during display for real-time brightness control
4. Code Quality and Integration (additional grade)
- Proper error handling
- Clear code organization
- Well-documented functions
- Smooth brightness transitions
- Comments
Technical Specifications
Timing Requirements
- Dot duration: 200ms
- Dash duration: 3 × dot duration
- Space between parts of letter: 1 × dot duration
- Space between letters: 3 × dot duration
- Space between words: 7 × dot duration
Starter Code
A base implementation is provided in 'morse_code_base.c'. You need to implement:
- Functions marked with TODO comments
- PWM initialization and control
- ADC reading and scaling
- LED brightness control
Testing Guidelines
-
Basic functionality:
- Verify correct Morse code timing
- Check LED on/off operation
-
Brightness control:
- Test minimum brightness (potentiometer at 0)
- Test maximum brightness (potentiometer at max)
- Verify smooth brightness transitions
-
Error conditions:
- Handle invalid input characters
- Manage boundary conditions for ADC/PWM values
Troubleshooting Tips
-
No LED output:
- Check physical connections
- Verify PWM initialization
- Confirm GPIO configuration
-
Incorrect brightness control:
- Verify ADC readings
- Check scaling calculations
- Test PWM duty cycle range
-
Timing issues:
- Use oscilloscope
- Add debug print statements
- Verify timer calculations
Leave a Comment