- #include <avr/io.h>
- #include <avr/interrupt.h>
- ISR(INT0_vect) {
- PORTB ^= (1 << PORTB7); // 翻转 PORTB7 引脚
- }
- int main(void) {
- // 配置 PORTB7 为输出
- DDRB |= (1 << DDB7);
- // 配置 INT0 为上升沿触发
- EICRA |= (1 << ISC01) | (1 << ISC00);
- EIMSK |= (1 << INT0);
- // 使能全局中断
- sei();
- while (1) {
- // 主循环
- }
- }
|