Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab Exercise 3: Using the four-step development process, write and run a C progr

ID: 3738185 • Letter: L

Question

Lab Exercise 3: Using the four-step development process, write and run a C program for an LED display system using the Dragon 12-Plus board. The system includes eight LEDs and the DIP-8 switch SW1 on the board. When all the switches on DIP-8 are OFF, the display should in sequence continue to light up LEDO, light up LED2, turn off LEDO, turn off LED2 each witha delay of 0.5 sec. When any switch in DIP-8 is turned ON, the display sequence should change as follows: light up LED7, light up LEDS, turn off LED7, turn off LEDS each with a delay of 0.5 sec. Enter CodeWarrior using "Create New Project." /0.5 s delay routine / void delay) int i,j; for(i 0 i

Explanation / Answer

#include <hidef.h> //common definitions and important macros

#include "derivative.h" // derivative-specific definitions and information

void Snooze(unsigned int);

void main(void)

{

PLL_init();

DDRB = 0xFF; //Output for PORTB

DDRP = 0xFF; //Output for PORTP

for(;;) //Unending for loop

{

PORTB = 0x5B;   

PTP = 0x0E;   

Snooze(1);   

PORTB = 0x3F;

PTP = 0x0D;

Snooze(1);

  

PORTB = 0x06;

PTP = 0x0B;

Snooze(1);

  

PORTB = 0x7F; //Number 8

PTP = 0x07;

Snooze(1);

}

}

void Snooze(unsigned int timing)  

{

unsigned int a;

unsigned int b;

for(a=0;a<timing;a++)

for(b=0;b<4000;b++);

}