They are not two questions, both are related to each other. 4. Program 3: Rewrit
ID: 3887795 • Letter: T
Question
They are not two questions, both are related to each other. 4. Program 3: Rewrite Example 3.5, but instead of displaying a value on the 7-segment display, your program should turn on the four LEDs. For example, if i=0, case 0 should be true and LED1 should turn on, if i = 1, case 1 should be true and LED2 should turn on, and so on for all four LEDs. You might want to review Example 3.1 on how to use the LEDs on the mbed. 5. Program 4: Rewrite your third program, but use an if/ else ifl else structure as seen on pages 348 and 349
Explanation / Answer
#include"mbed.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
int main()
{
while(1)
{
for(inti=0;i<4;i++)
{
switch (i)
{
case 0:led1=1;break;//turn on led1
case 1:led2=1;break;//turn on led2
case 2:led3=1;break;//turn on led3
case 3:led4=1;break;//turn on led4
}
wait(0,2);
}
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.