Question
1. Assume there are 8 LEDs on a development board and also assume that LEDs blink with step 1 and 2 pattern recursively on 8 LEDs as illustrated in Fig. 1
. Also assume that the LEDs are active-high enabled on the develop
ment board.
a. Write a C program that performs a LED blinking pattern. Grading: header/include file declaration (1 pts), I/O ports declaration (1 pts), delay function (1 pts), LED patterns (7 pts)
b. Draw a LED wiring diagram that allows a LED to come on with a low signal and to come off with a high signal.
Assume there are 8 LEDs on a development board and also assume that LEDs blink with step 1 and 2 pattern recursively on 8 LEDs as illustrated in Fig. 1 Also assume that the LEDs are active-high enabled on the develop ment board. Write a C program that performs a LED blinking pattern. Grading: header/include file declaration , I/O ports declaration , delay function , LED patterns Draw a LED wiring diagram that allows a LED to come on with a low signal and to come off with a high signal.
Explanation / Answer
#include #define F_CPU 4000000UL #include int main() { DDRC = 0xFF; // Configure port C as output... while(1) { PORTC = 0xAA; // Turn ON LEDs _delay_ms(250); // Wait 250ms... u can change this if u want PORTC = 0x55; // Turn OFF LEDs _delay_ms(250); // Wail 250ms } return 0; }