problem with simple IF statement

I have this code, this is for touch screen area, it maps the area fine, but when K is not 1, it shouldn't go there but it does, I tried 2 statements if, does not work. When it calls function secondScreen(); k is set to 2. So this area is not mapped anymore or mapped differently on other screen.

if ( (y>220) && (y<300) && (x>40) && (x<460) && (k=1))

{
secondScreen();
Serial.println(k);

}

== not =

thanks, it did not show any errors, I changed to == works now

ED201:
thanks, it did not show any errors, I changed to == works now

That is because it is not a syntax error. It is a logic error you made.

Paul

Paul_KD7HB:
That is because it is not a syntax error. It is a logic error you made.

Paul

It's a good thing the compiler doesn't flag logic errors. My code would never compile. 8)