10 Replies Latest reply on Apr 2, 2014 3:47 PM by simon.kristensen

    If statement and &&

              Hello I cant make this simple code work: if ((PRT0DR & pin5) && (startknap_lys==0)){startknap_lys=1;PRT0DR |= pin3;while(PRT0DR & pin5){}} It only has to check in input port and a value in an int. If I remove the integer it works fine. I have made it work before with checking two variables in an if statement. Both with & or &&. This has worked before: if ((value<=15)&&(value>=5)&&(skygge==1)){} And this aswell: if( (LDR_1 < 51) & (LDR_2 < 51) & (LDR_3 < 51) & (LDR_4 < 51) ) //Checking the light intensity on all 4 LDR´s So I cant seem to figure out why it doesn't want to work now. Though this is the first time I check both and input port and a variable and not only variables. Thanks And for the record, my code works, just not when I add the variable. This is the whole code: