Embedded C Use the IDE of your choice: Eclipse, Pelles C CodeWarrior, etc Write
ID: 3733526 • Letter: E
Question
Embedded C Use the IDE of your choice: Eclipse, Pelles C CodeWarrior, etc Write a program to make a remote control using the H CS 12 board by doing the following: 1- when you press a number in the keypad, the Chanel number will show in the LCD 2-Use # and * to turn the volume up and down by using the buzzer to make load and low sound. 3-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. 4Use key 0 to turn the nExplanation / 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--;
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.