ATmega32 LED Blink (PC0)
This tutorial explains how to blink an LED using the ATmega32 microcontroller.
🔌 LED Connection
- LED is connected to PC0
✅ Logic Type: Active-HIGH
PC0 = 1 → LED ONPC0 = 0 → LED OFF
⚙️ Requirements
Hardware
- ATmega32 Development Board
- ATMEL AVR 8051 USBasp ISP Programmer
- LED + 470Ω resistor (if not on-board)
Software
- Atmel Studio / Microchip Studio / AVR-GCC
- Programmer software (e.g., AVRDude)
🧱 Project Setup
- Open your AVR IDE (Atmel Studio / Microchip Studio)
- Create a New GCC C Project
- Select device: ATmega32
- Add a new file:
main.c
💡 LED Blink Code
Note: Delay depends on CPU frequency. Here we assume 12 MHz.
#define F_CPU 12000000UL // CPU frequency
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
// Set PC0 as output
DDRC |= (1 << PC0);
// LED OFF initially
PORTC &= ~(1 << PC0);
while (1)
{
// LED ON
PORTC |= (1 << PC0);
_delay_ms(500);
// LED OFF
PORTC &= ~(1 << PC0);
_delay_ms(500);
}
}