Get Solutions for: Using Atmel AVR Dragon ( contains ATmega16 chip). Modify theexisting C source code to add 3 more LED

Using Atmel AVR Dragon ( contains ATmega16 chip). Modify theexisting C source code to add 3 more LEDs to PC1,PC2,PC3. If SW0 isactive flash PC0 once, if SW1 is active flash PC1 twice, if SW3 isactive flash PC2 3 times, if SW3 is active flash PC3 4 times
/************************** Keypad********************************/ /*                                 */ /*   A four switch keypad is connected to the controller*/ /*   using standard scanning techniques.          */ /* PortB0 and B1 are outputs, PORTB1 and B2 are inputs  */ /* PortC0 is an output to an LED level indicator.      */ /*                                 */ /* Note that the LCD is used here even though it is not  */ /* required for the project. It is used for development  */ /* and troubleshooting – and then deleted from thefinal   */ /* release of the project.                  */ /*                                 */ /*   B. Stefanchuk               July 2011  */ /*                                 */ /*********************** INCLUDES (libraries)*********************/
#include #include
/****************************** DEFINITIONS***********************/
/****** DECLARATIONS ( variables and function prototypes)*********/
void LCDstr (char *strg); void LCDinit(void); char DefaultMessage[] = “I love Embedded Systems”; char Switch1[] = “Switch 1 is active”; char Switch2[] = “Switch 2 is active”; char Switch3[] = “Switch 3 is active”; char Switch4[] = “Switch 4 is active”; Strobe(); Clear_Display(); Unpack_To_PortD(char data); Short_Delay(); Port_Init(); FlashLED();
/******************************************************************/
/**************************** MAIN********************************/ void main(void) {   LCDinit(); Port_Init(); Clear_Display(); LCDstr (DefaultMessage); delay_ms(1500); Clear_Display(); while(1) { PORTB = PORTB & 0b11111110;       //Lower PB0 PORTB = PORTB | 0b00000010;       // RaisePB1    if ((PINB & 0b00000100)==0)    {           LCDstr (Switch1);      // Display switch 1 active        FlashLED();          // Flash LED once        delay_ms(100);        Clear_Display();    }              if ((PINB & 0b00001000)==0)    {          LCDstr (Switch2);      // Display switch 2 active        FlashLED();          // Flash LED twice        FlashLED();          delay_ms(50);        Clear_Display();                       }               PORTB = PORTB & 0b11111101;       //Lower PB1 PORTB = PORTB | 0b00000001;       // RaisePB0    if ((PINB & 0b00000100)==0)      {        LCDstr (Switch3);      // Display switch 3 active           FlashLED();          // Flash LED threetimes        FlashLED();        FlashLED();        Clear_Display();    }               if ((PINB & 0b00001000)==0)    {          LCDstr (Switch4);      // Display switch 4 active        FlashLED();          // Flash LED four times        FlashLED();             FlashLED();        FlashLED();        Clear_Display();             }       }   }
/************************ MACROS AND FUNCTIONS********************/
void delay_ms(int d) { for(int i = 0;i{ _delay_ms(2); } }   /******************************************************************/    /*********************** LCD_Init********************************/
void LCDinit(void)          // Initialize LCD           { DDRD = 0xFF;           //Port D is output          PORTD = 0x00;           //E = 0                  delay_ms(5);           //Wait for LCD             PORTD = PORTD & 0x0F;       // maskaway high nibble from Port D PORTD = PORTD | 0x20;       // enable4-bit data transfer Strobe(); Unpack_To_PortD(0x28);       // enable4-bit data transfer Unpack_To_PortD(0x0C);       // displayon, no cursor Unpack_To_PortD(0x06);       // cursorshifts right Clear_Display(); }
/******************************************************************/
void LCDstr(char *strg)       // Outputa string of characters {       char character;          // Exits loop when character = NULL       PORTD = PORTD | 0b00000100;   // E = 1              PORTD = PORTD & 0b11111101;   //   RW =0, PORTD = PORTD | 0b00000001;   // RS = 1(Data)                 while (character = *strg) { Unpack_To_PortD(character);   // write data to LCD *strg++; } }
/************************** Strobe********************************/
Strobe() { PORTD = PORTD | 0b00000100;   //   E =1              Short_Delay;   PORTD = PORTD & 0b11111011;   //   E =0              delay_ms(1); }
/************************ Clear_Display***************************/
Clear_Display() { PORTD = PORTD | 0b00000100;   // E = 1              PORTD = PORTD & 0b11111100;   //   RW = 0,RS = 0 (Cmd)   Short_Delay();           //Wait for LCD                Unpack_To_PortD(0x01);       // clearLCD Unpack_To_PortD(0x02);       // cursorhome }
/*************************** Short Delay**************************/ Short_Delay() { char i; for (i=0; i} /******************************************************************/
/*************************** LCD Write*****************************/
Unpack_To_PortD(char data) { char temp; temp = data; PORTD = PORTD & 0x0F;   // mask away high nibble fromPort D data = data & 0xF0;       // mask awaylow nibble from data PORTD = PORTD | data;   // data low nibble to Port D highnibble Strobe(); PORTD = PORTD & 0x0F;   // mask away high nibble fromPort D temp = temp PORTD = PORTD | temp;   // data low nibble to Port D highnibble Strobe(); }
/**************************** Flash LED************************/
FlashLED() { PORTC = PORTC | 0b00000001; delay_ms(250); PORTC = PORTC & 0b11111110;   //   FlashLED once delay_ms(250); }
/**************************** Port_Init*************************/
Port_Init() { DDRB = DDRB | 0b00000011;   // PortB0 and PB1 areoutputs PORTB = PORTB & 0b00000000;   // PortB0 and PB1 are0 DDRC = DDRC | 0b00000001;   // PortC0 is an output PORTC = PORTC & 0b00000000;   // Lower PC0 }   /****************************** END*******************************/
.
Attached