digital read from another microcontroller

HI,
I'm trying to use an ardumoto shield, an arduino and another (3v) microcontroller device to control both the arduino/ardumoto

I have a power supply for my arduino/ardumoto and a separate power supply for my other device.

I have connected ground from my other device to GND (above pin13) on the arduino
I have three outputs from my device connected to inputs 5, 6, 7 on the arduino.

I am expecting something to happen when I turn one or more of these outputs high, and that correspondingly my arduino should pick this up with digitalread in an if statement but nothing happens :confused:

(All I see is stop stop stop ... on my serial monitor.)

My sketch is here ...

// Clockwise and counter-clockwise definitions.
// Depending on how you wired your motors, you may need to swap.
#define CW 0
#define CCW 1

// Motor definitions to make life easier:
#define MOTOR_A 0
#define MOTOR_B 1

// Pin Assignments //
// Don't change these! These pins are statically defined by shield layout
const byte PWMA = 3; // PWM control (speed) for motor A
const byte PWMB = 11; // PWM control (speed) for motor B
const byte DIRA = 12; // Direction control for motor A
const byte DIRB = 13; // Direction control for motor B

int pin0 = 5; //for reading the outputs from the other device
int pin1 = 6;
int pin2 = 7;

void setup()
{
Serial.begin(9600);
setupArdumoto(); // Set all pins as outputs
pinMode(pin0, INPUT);
pinMode(pin1, INPUT);
pinMode(pin2, INPUT);
}

void loop()
{
Serial.println("main loop");
// 000 all stop
if ((digitalRead(pin0 == LOW)) && (digitalRead(pin0 == LOW)) && (digitalRead(pin0 == LOW)))
{
Serial.println("stop");
stopArdumoto(MOTOR_A);
stopArdumoto(MOTOR_B);
}
//001 left
else if ((digitalRead(pin0 == LOW)) && (digitalRead(pin0 == LOW)) && (digitalRead(pin0 == HIGH)))
{
Serial.println("left");
driveArdumoto(MOTOR_A, CCW, 255);
driveArdumoto(MOTOR_B, CW, 255);
}

//010 right
else if ((digitalRead(pin0 == LOW)) && (digitalRead(pin0 == HIGH)) && (digitalRead(pin0 == LOW)))
{
Serial.println("right");
driveArdumoto(MOTOR_A, CW, 255);
driveArdumoto(MOTOR_B, CCW, 255);
}
//100 forward
else if ((digitalRead(pin0 == HIGH)) && (digitalRead(pin0 == LOW)) && (digitalRead(pin0 == LOW)))
{
Serial.println("forward");
driveArdumoto(MOTOR_A, CCW, 255);
driveArdumoto(MOTOR_B, CCW, 255);
}
//101 reverse
else if ((digitalRead(pin0 == HIGH)) && (digitalRead(pin0 == LOW)) && (digitalRead(pin0 == HIGH)))
{
Serial.println("reverse");
driveArdumoto(MOTOR_A, CW, 255);
driveArdumoto(MOTOR_B, CW, 255);
}
}

// driveArdumoto drives 'motor' in 'dir' direction at 'spd' speed
void driveArdumoto(byte motor, byte dir, byte spd)
{
if (motor == MOTOR_A)
{
digitalWrite(DIRA, dir);
analogWrite(PWMA, spd);
}
else if (motor == MOTOR_B)
{
digitalWrite(DIRB, dir);
analogWrite(PWMB, spd);
}
}

// stopArdumoto makes a motor stop
void stopArdumoto(byte motor)
{
driveArdumoto(motor, 0, 0);
}

// setupArdumoto initialize all pins
void setupArdumoto()
{
// All pins should be setup as outputs:
pinMode(PWMA, OUTPUT);
pinMode(PWMB, OUTPUT);
pinMode(DIRA, OUTPUT);
pinMode(DIRB, OUTPUT);

// Initialize all pins as low:
digitalWrite(PWMA, LOW);
digitalWrite(PWMB, LOW);
digitalWrite(DIRA, LOW);
digitalWrite(DIRB, LOW);
}

 if ((digitalRead(pin0 == LOW)) && (digitalRead(pin0 == LOW)) && (digitalRead(pin0 == LOW)))

Nonsense. pin0 is 5. That is NOT LOW, so reading pin false won't make any sense. Reading it three times makes even less sense.

Put your parentheses in the right places.

 if ((digitalRead(pin0 == LOW)) && (digitalRead(pin0 == LOW)) && (digitalRead(pin0 == LOW)))

Why are you reading the same input 3 times and using digitalRead() wrongly in each case ?

I feel so stupid...
In my defense someone unplugged my computer 10 minutes before I needed this, lost my work, messed up the session I needed it for and I've been in a blind panic since then.
Blindly copy pasting and going into panic mode testing with leds, swearing....

Obviously it should be if pin0, pin1, pin2
If (digitalread(pin0)==LOW) &&...
Sometimes it just takes someone calm to help

Thanks

Obviously it should be if pin0, pin1, pin2

That's one of the problems. The other is that you are not reading from those pins...