Answer to Question #154156 in C for Rakibul

Question #154156

Write C code for Atmega32 programming for the following scenario:

Create a LED pattern with 8 LEDs which will represent the BCD value 0101 1000


Example:

The pattern will start to loop in the following order.

Loop:

{

First 0101 will be on and 1000 will be off for 2.5 seconds.

Next, 0101 will be off and 1000 will be on for 2.5 seconds.

Next, all 0101 and 1000 will be on for 2.5 seconds.

Next, all will be off for 2.5 seconds.

}


1
Expert's answer
2021-01-07T09:28:40-0500
#ifndef F_CPU
#define F_CPU 16000000UL // 16 MHz clock speed
#endif

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
  DDRC = 0xFF; //Nakes PORTC as Output
  while(1) //infinite loop
  {
    PORTC =0x5;
    _delay_ms(2500);
    PORTC= 0x00;
    _delay_ms(2500);
    PORTC =0x8;
    _delay_ms(2500);
    PORTC= 0x00;
      PORTC =0x5;
      PORTC =0x8;
       _delay_ms(2500);
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS