arduino - switch case with an if statement not working when true -


i using switch case if statement inside touch screen touches

the following code returning true via serial terminal confirming touch coordinates value page set in beginning of code 0 until main screen loads switches 1 (again confirmed serial terminal) though have confirmed true not run true event (which serial print command @ moment.

int page = 0;     // page number active 

this @ top of code includes

then in main loop

     switch (page) {       // --------------check see if screen 1 loaded-----------------    case '2': {  // screen 1 active when screen 1 loads chages value of page 1     if ((p.x > 137 && p.x < 210)&& (p.y > 280 && p.y < 320))     serial.print("option1");            else if ((p.x > 80 && p.x < 112)&& (p.y > 280 && p.y < 320))     serial.print("option1.2");        else if ((p.x > 45 && p.x < 85)&& (p.y > 280 && p.y < 320))     serial.print("option1.3");        else if ((p.x > 5 && p.x < 24)&& (p.y > 280 && p.y < 320))     serial.print("option1.4");  break;} 

the main screen loads after setup , turns page value 1

void mainmenu(){   page = 1;   serial.print("initializing sd card...");   if (!sd.begin(sd_cs)) {     serial.println("failed!");   }   serial.println("ok!");   tft.fillscreen(black);    title();   grid();   buttons();   { 

values returned serial terminal after pressing button 1

p.x more 137 p.x less 210 p.y more 280 p.x less 320  x 196 & y 310  page value= 1 

but still no message serial.print("option1")

i have broken down if statement separate values , each returns true can think of it's in case line i'm not sure what

did try change line

case '2': {  

with one?

case 2: {  

also try put println after case sure switch statement works fine

case 2: {            serial.println("entered in case 2"); 

Comments