Robot Programming Question

I am programming a simple robot to go when a button is pressed, and to stop if it isn’t. I am using a nunchuck as the button. The code is pretty self explanatory; the digitalWrite commands set the direction of the motor to forward, and the analogWrite commands set the power of the motor. When I upload the code, the motors run at full speed, even if the if statement isn’t true. I have no idea what’s going on here! Any ideas?

int y;
int x = 0;
int b;

#include <Wire.h>
#include "nunchuck_funcs.h"

void setup()
    pinMode(3, OUTPUT);  //Set control pins to be outputs
    pinMode(11, OUTPUT);
    pinMode(12, OUTPUT);
    pinMode(13, OUTPUT);

void loop()
        b = 0;
        b = nunchuck_zbutton();
        if (b = 1) {
          digitalWrite(12, HIGH);
          analogWrite(3, 255);  //set both motors to run at 100% duty cycle (fast)
          analogWrite(11, 255);
        if (b = 0) {
          digitalWrite(12, HIGH);
          analogWrite(3, 0);  //set both motors to run at 100% duty cycle (fast)
          analogWrite(11, 0);
        else {

b = 1 is always true.
Try == for comparisons

Also, b= 0 is always false, try "else" when you've fixed the other part of the comparison.

Thanks AWOL! I changed the "=" to a "==" and that solved the problem.