This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

If statements

Hi, Currently doing a project for college and have come to a road block. I have function which has a if statement. There are five different possible
outcomes for the if statement. The outcome depends on four different inputs, the fifth
one is null. The problem i'm having is I don't want to come out of the if statement if
there's no change to the input. I'm using a do while statement with the if statement. temp_read is the variable I store the value of which if statement is being used. Hope someone understands what i'm trying to say.

Thanks Thomas

void read_braking(void)
{ unsigned char temp_read; unsigned char total_secs; unsigned char new_min; unsigned char new_hrs; unsigned char new_read; total_secs = 0x00; temp_read = 0x00; new_read = 0x00;

do
{ if((thinking == 1) && (easy == 0) && (medium == 0) && (hard == 0)) { yellow_led = ON; green_led = OFF; amber_led = OFF; red_led = OFF; temp_read = 0x08; }

else if((thinking == 1) && (easy == 1) && (medium == 0) && (hard == 0)) { yellow_led = ON; green_led = ON; amber_led = OFF; red_led = OFF; temp_read = 0x0C; }

else if((thinking == 1) && (easy == 1) && (medium == 1) && (hard == 0)) { yellow_led = ON; green_led = ON; amber_led = ON; red_led = OFF; temp_read = 0x0E; }

else if((thinking == 1) && (easy == 1) && (medium == 1) && (hard == 1)) { yellow_led = ON; green_led = ON; amber_led = ON; red_led = ON; temp_read = 0x0F;

}

else { yellow_led = OFF; green_led = OFF; amber_led = OFF; red_led = OFF; temp_read = 0x00; }

}

while (temp_read == temp_read);

external_write(temp_read);

return;
}

0