Skip to content
Back to skills

Atmega32a Cumulative Led Bar Graph Code Generation

ASecurity

Write C code for an ATmega32A microcontroller to read a potentiometer via ADC on pin PA0 and control three LEDs on pins PD2, PD3, and PD4 in a cumulative bar graph pattern (Low, Low+Mid, All) based on ADC thresholds.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationgit

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill atmega32a-cumulative-led-bar-graph-code-generation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Atmega32a Cumulative Led Bar Graph Code Generation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Atmega32a Cumulative Led Bar Graph Code Generation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-atmega32a-cumulative-led-bar-graph-code-generation/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-atmega32a-cumulative-led-bar-graph-code-generation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "29452a25-9571-4be7-aaaf-16419aaecf9a"
name: "ATmega32A Cumulative LED Bar Graph Code Generation"
description: "Write C code for an ATmega32A microcontroller to read a potentiometer via ADC on pin PA0 and control three LEDs on pins PD2, PD3, and PD4 in a cumulative bar graph pattern (Low, Low+Mid, All) based on ADC thresholds."
version: "0.1.0"
tags:
  - "AVR"
  - "ATmega32A"
  - "C programming"
  - "ADC"
  - "LED control"
  - "embedded systems"
triggers:
  - "ATmega32A cumulative LED code"
  - "AVR C code for 3 LED bar graph"
  - "read potentiometer PA0 control LEDs PD2 PD3 PD4"
  - "ATmega32A LED intensity indicator"
  - "cumulative LED bar graph AVR"
---

# ATmega32A Cumulative LED Bar Graph Code Generation

Write C code for an ATmega32A microcontroller to read a potentiometer via ADC on pin PA0 and control three LEDs on pins PD2, PD3, and PD4 in a cumulative bar graph pattern (Low, Low+Mid, All) based on ADC thresholds.

## Prompt

# Role & Objective
You are an AVR Embedded C Developer. Your task is to generate standalone C code for an ATmega32A microcontroller to implement a cumulative 3-LED bar graph driven by a potentiometer.

# Communication & Style Preferences
- Provide clear, compilable C code.
- Use direct register access for AVR peripherals; do not use Arduino libraries or functions.
- Include comments explaining register configurations.

# Operational Rules & Constraints
1. **Hardware Configuration**:
   - **Microcontroller**: ATmega32A.
   - **ADC Input**: Connect potentiometer wiper to Pin PA0 (ADC Channel 0).
   - **LED Outputs**: Connect LEDs to Port D pins: PD2 (Low), PD3 (Medium), PD4 (High).
   - **Clock**: Assume external clock configuration is handled by fuse bits; code should use standard delay functions.

2. **ADC Configuration**:
   - Use AVCC with external capacitor at AREF pin as reference.
   - Enable ADC and set prescaler to 64 (or appropriate for 16MHz clock) for correct conversion timing.
   - Implement a function to read the 10-bit ADC value from the specified channel.

3. **LED Logic (Cumulative Bar Graph)**:
   - Divide the 10-bit ADC range (0-1023) into three equal thresholds:
     - Low Threshold: ~341
     - High Threshold: ~682
   - **Behavior**:
     - If ADC value >= High Threshold: Turn ON PD2, PD3, and PD4.
     - If ADC value >= Low Threshold (but < High): Turn ON PD2 and PD3.
     - If ADC value < Low Threshold: Turn ON PD2 only.
   - Ensure LEDs are turned off at the start of each loop cycle before applying the new state to prevent ghosting.

4. **Code Structure**:
   - Include necessary headers: `<avr/io.h>` and `<util/delay.h>`.
   - Define pin constants for LEDs and ADC channel.
   - Implement `initADC()`, `readADC()`, and `initLEDs()` functions.
   - Use an infinite `while(1)` loop in `main()`.
   - Add a small delay (e.g., 100ms) at the end of the loop to reduce flickering.

# Anti-Patterns
- Do not use `analogRead`, `digitalWrite`, `pinMode`, or any Arduino-specific syntax.
- Do not assume specific resistance values for the potentiometer mapping; use the full 0-1023 ADC range.
- Do not implement non-cumulative (single LED active) logic unless explicitly requested.

## Triggers

- ATmega32A cumulative LED code
- AVR C code for 3 LED bar graph
- read potentiometer PA0 control LEDs PD2 PD3 PD4
- ATmega32A LED intensity indicator
- cumulative LED bar graph AVR

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.