Coding in embedded C please HW05-1 Develop an algorithm which generates an infin
ID: 2248033 • Letter: C
Question
Coding in embedded C please HW05-1 Develop an algorithm which generates an infinite loop with two LED outputs: Each iteration is approximately I second. . Define one variable, LEDIfor the Red LED. o Define another variable, LED2, for the Green LED o The Red LED turns ON for 500ms, then turns OFF 500ms, every iteration. The Green LED turns ON when the Red LED is OFF, and OFF when the Red LED is ON. Document this algorithm using a flowchart or pseudo-code. For a flowchart, use an online tool such as "draw.io" (or powerpoint). Hand-written drawings (sketches) ARE NOT acceptable for this HW assignment. SPRING 2017 DSTR-ENGRI12 Hwos For pseudo-code, use a simple text file and standard pseudo-code protocol. Use the variable names specified and document (explain) any additional variables. . .Explanation / Answer
// File inclusion
// LED1 -- > RED LED
// LED2 -- > RED LED
#define LED1_OFF { LED_1 = 0; ledstatus.LED1 = 0; }
#define LED2_OFF { LED_2 = 1; ledstatus.LED2 = 0; }
#define LED1_ON { LED_1 = 1; ledstatus.LED1 = 1; }
#define LED2_ON { LED_2 = 1; ledstatus.LED2 = 1; }
// Need replace above macro with GPIO / PORT insted of variable LED_1 and LED_2 depends upon the hardware.
typedef struct __LEDs
{
unsigned LED1 :1;
unsigned LED2 :1;
}LEDs;
LEDs ledstatus;
unsigned char LED_1,LED2;
void main()
{
// Intilization
LED1_OFF;
LED2_OFF;
while(1)
{
LED2_OFF;
LED1_ON;
delay_ms(500);
LED1_OFF;
LED2_ON;
delay_ms(500);
}
}
//
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.