Assume that eight DIP switches are connected to PORTB and eight LEDs are connect
ID: 1812352 • Letter: A
Question
Assume that eight DIP switches are connected to PORTB and eight LEDs are connected to PORTC. Assume that the switch values are normally high. Turn all of the LEDs on and wait in a loop until one of the switches becomes zero. At that time, send 0x55 to PORTC. Please write in C. I am using the HCS12 Assume that eight DIP switches are connected to PORTB and eight LEDs are connected to PORTC. Assume that the switch values are normally high. Turn all of the LEDs on and wait in a loop until one of the switches becomes zero. At that time, send 0x55 to PORTC. Please write in C. I am using the HCS12Explanation / Answer
Executable code
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
int portB = 11111111;
int portC=00000000;
printf(" all leds are off ");
portC= (portC|255 );
printf("%x ",portC);
printf(" now all leds are 0 ");
for(i=0;i<8;i++)
{
if(portC!=11111111)
{
portC=55;
printf("%d ",portC);
break;
}
}
getch();
return 0;
}
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.