这个例程序是用74HC138 及74HC154做的逻辑控制例程。
就是用IO引脚的高低变化控制输出:
Proteus 仿真截图:
Studio6.2编译截图:
程序清单:
- /*
- * GccApplication17.c
- *
- * Created: 2014-11-14 21:35:11
- * Author: Administrator
- */
- #define F_CPU 1000000UL
- #include <avr/io.h>
- #include <util/delay.h>
- #include <stdint.h>
- int main(void)
- {
- DDRB = 0xFF;PORTB = 0x00;
- DDRC = 0xFF;PORTC = 0x00;
- while(1)
- {
- PORTB = (PORTB+1)&0x07;
- PORTC = (PORTC+1)&0x0F;
- _delay_ms(80);
- //TODO:: Please write your application code
- }
- }
|