Assume that eight DIP switches are connected to PORTB and eight LEDs are connect
ID: 3533316 • 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 DO NOT COPY THE ANSWER FROM THE OTHER 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 DO NOT COPY THE ANSWER FROM THE OTHER QUESTION.....
Explanation / 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;
}