BLDC motor controller

Hi every one i have a BLDC motor and i need help with this code. in the if statements below if i put two == signs the motor would not run properly so I'm trying to do it like this: (PINB & B00000011) for each statement instead of having two == signs but it does not execute all of the statements for some reason ?? can any one help with this please, i don't understand why it doesn't work with (PINB & B00000011) ??

// clockwise

//int SensorA = 8;
//int SensorB = 9;
//int SensorC = 10;

void setup()
{

// pinMode(SensorA,INPUT);
// pinMode(SensorB,INPUT);
// pinMode(SensorC,INPUT);

DDRD |= B11111100; // Sets D2, D3, D4, D5, D6 and D7 as OUTPUT
PORTD &= B00000011; // D2 to D7 LOW

DDRB |= B11111000;

// Serial.begin (9600);

}

void loop()
{

if ( PINB == B00000011) {
//Serial.println("1");

PORTD = B11000000;

}

else if ( PINB == B00000010){
// Serial.println("2");

PORTD = B10010000;

}

else if ( PINB == B00000110){
// Serial.println("3");

PORTD = B00110000;

}

else if ( PINB == B00000100){
// Serial.println("4");
PORTD = B00100100;

}

else if ( PINB == B00000101) {
// Serial.println("5");
PORTD = B00001100;

}

else if ( PINB == B00000001 ){
// Serial.println("6");

PORTD = B01001000;

}

}

You should tell more, and format your code with code tags.

And how is your hardware, could you show the circuit so we can have an idea what you are doing?

Cheers,
Kari

void setup()
{

DDRD |= B11111100; // Sets D2, D3, D4, D5, D6 and D7 as OUTPUT which go to the 6 MOSFETs in a inverter circuit for a BLDC motor
PORTD &= B00000011; // D2 to D7 LOW

// Serial.begin (9600);

}

void loop()
{

// inside the if and else if statements are the readings from the hall effect sensors on a BLDC motor

if ( PINB == B00000011) { // if the folowwing reading is true than execute this statement
//Serial.println("1");

PORTD = B11000000; // pins 7 and 6 are high

}

else if ( PINB == B00000010){
// Serial.println("2");

PORTD = B10010000; // pins 7 and 4 are high

}

else if ( PINB == B00000110){
// Serial.println("3");

PORTD = B00110000; // 5 and 4 are high

}

else if ( PINB == B00000100){
// Serial.println("4");
PORTD = B00100100; // 5 and 2 are high

}

else if ( PINB == B00000101) {
// Serial.println("5");
PORTD = B00001100; // 2 and 3 are hgih

}

else if ( PINB == B00000001 ){
// Serial.println("6");

PORTD = B01001000; // 6 and 3 are high

}

}

hi I have reposted the code with comments i don't have the schematic with me, is just 6 pins from the Arduino going to the inverter circuit to control a BLDC motor, the problem is in the control statements if i have e.g. if (PINB == B0000100) it kind of works but i want to change them to (PINB & B0000100) but it dosent go to all of the condition when i do that. the reason why i want to change it is because i think when i use == it slows the program down and the hall effect sensors are not in sync by the time it outputs from the digital pins.

GaryP:
Format your code with code tags.

Try again.

Yes, use code tags.
Before you post the code, auto format using CTRL-T
And PLEASE remove all of the unnecessary white space.
The code is much easier to read if it does not have 37 blank lines spreading the code across multiple pages.