i wish to check whether the bit i in the data word "Address" is "1" or "0". So i decided to use for loop and bitwise. But I'm not sure if the code is correct. My address is 0b0110000111010110. Heres the code:
Is the above code correct?Code:unsigned char a = 0b000000000001; for (i=0 ; i < 16 ; i++) { //checks whether the bit i in the data word "Address" is "1" or "0" if (Address && a) !=0 // ==> True if Bit 1 is a logic "1", else False { // output a logic "1": for (j=0 ; j < 21 ; j++) { G1_LED2 = 1; DelayUs(9); G1_LED2 = 0; DelayUs(9); } DelayUs(1690); } else { // output a logic "0" for (j=0 ; j < 21 ; j++) { G1_LED2 = 1; DelayUs(9); G1_LED2 = 0; DelayUs(9); } DelayUs(560); } a = a <<1; i++; }
Im currently using MPlab and seriously, i do not know what compiler i am using. Any recommendations for compilers that i can download frm the net?
Thanks!!