Simply switch off what needs to be switched off if a condition is true and switch on what needs to be switched on if the condition is true.
if (condition1)
{
// switch off what needs to be off
...
// switch on what needs to be on
...
}
else if (condition2
{
// switch off what needs to be off
...
// switch on what needs to be on
...
}
else if (condition3)
{
// switch off what needs to be off
...
// switch on what needs to be on
...
}
else
{
// switch all off
...
}
Replace conditionX by the conditions like 'rValue <= 255'.