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

Problem 2. Consider a light system that is controlled by an 8-bit register, whic

ID: 2267793 • Letter: P

Question

Problem 2. Consider a light system that is controlled by an 8-bit register, which carries a command to the light system. We call this register Light System Command or LSC. Here are the specifications of this register: . Bit 0-1 control the light intensity: 00 off, 01 low, 10 medium, 11 high. Bit 2-4 control the color: blue 000, green 001, red 010, yellow 011, white 100. Example: If we assign OxC3 to LSC, the light system will interpret it as "It should turn on lamp number # 6 with highest intensity in blue color."

Explanation / Answer

Hello,
       Please find the answer attached below. If the answer has helped you please give a thumbs up rating. Thank you and have a nice day!

The LSC controls three attributes of the light, out of which only the color of the light is of interest to us. The bits 2-4 controls the color i.e. we have to analyse bits xx234xxx out of the given integer, x's being dont care. Since the integer is of 8 bits, valid inputs range from 0 till 255. The bits can be extracted by multiplying the integer with 00111000, i.e. 28. If the integer is multiplied with 28, valid outputs are 00000000 (=0=blue), 00001000 (=16 = green), 00010000 (=8 = red), 00011000 (=24=yellow) and 00100000 (= 4=white). Thus the function will look like this:

int extractColor(int b)

{

      int BLUE = 0; int GREEN = 1; Int RED = 2; int YELLOW = 3; int WHITE = 4 ; int NO_COLOR = 9;    // number coding for colors

     switch(b*28)

     {

             case (0) : return BLUE;

            case (16) : return GREEN;

           case (8): return RED

            case (24) : return YELLOW;

           case (4) : return WHITE;

          default: return NO_COLOR;

     }

      

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote