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

C programing create a code to make a remote control using the HCS 12 board by do

ID: 3733452 • Letter: C

Question

C programing create a code to make a remote control using the HCS 12 board by doing the following: when you press a number in the keypad, the Chanel number will show in the LCD. Use # and * to turn the volume up and down by using the buzzer to make load and low sound. 1- 2- use the LED to show how load or low the sound is. For example, the lowest is 1 and the highest is 10 if you press # the number will change to 2 in the LED and the sound will be louder. 3- 4. Use key 0 to turn the remote control off and on

Explanation / Answer

public class TVRemote implements RemoteControl

{

private boolean power;

private boolean muted;

private int MIN_CHANNEL = 2;

private int MAX_CHANNEL = 10;

private int channel;

private int MIN_VOLUME = 0;

private int MAX_VOLUME = 10;

private int volume;

private boolean checkMute = true; // added to check if muted is true or false

public TVRemote()

{

boolean power = false;

muted = false;

channel =MIN_CHANNEL;

volume = MIN_VOLUME;

}

public boolean getPower()

{

return power;

}

public boolean getMuted()

{

return muted;

}

public int getChannel()

{

return channel;

}

public int getVolume ()

{

return volume;

}

public void powerOnOff()

{

if (power)

muted = muted;

else

power =! power;

}

public void mute ()

{

if (power)

muted =!muted;

}

public void channelUp ()

{

if (power)

{

if (channel == MAX_CHANNEL)

{

channel = MIN_CHANNEL;

}

else

{

channel++;

}

}

}

public void channelDown()

{

if (power)

{

if (channel == MIN_CHANNEL)

{

channel = MAX_CHANNEL;

}

else

{

channel--;

}

}

}

public void volumeUp ()

{

if (power)

{

if (muted == checkMute || volume = MAX_VOLUME) // check if tv is muted 'OR' at MAX_VOLUME

{

System.out.println("Volume is maxxed, or tv is muted");

}

else

{

volume++;

}

}

public void volumeDown ()

{

if (power)

{

if (muted == checkMute || volume = MIN_VOLUME) // check if tv is muted 'OR' at MIN_VOLUME

{

System.out.println("Volume is at min., or tv is muted");

}

else

{

volume--;

}

}

}

}