arduinosparkcore

Powering DC Motor with Spark Core and arduino motor shield R3


I am trying to run a motor shield without the shield shield with a spark core. I got an Arduino to run the motor shield using this code :

int a = 12;
int abrake = 9;
int aspeed = 3;

void setup()
{
  // Initialize D0 pin as output
  pinMode(a, OUTPUT);
  pinMode(abrake, OUTPUT);
}

// This routine loops forever
void loop()
{
  digitalWrite(a, HIGH);
  digitalWrite(abrake, LOW);
  analogWrite(aspeed, 225);
}

I then wiped the arduino so it wasn't running any code but was powering the shield. Then I tried to use a spark core to control the motor shield.

I hooked

D0 -> 12

D1 -> 9

D0 -> 3

And used this code :

int a = D0;
int abrake = D1;
int aspeed = D2;

void setup()
{
  // Initialize D0 pin as output
  pinMode(a, OUTPUT);
  pinMode(abrake, OUTPUT);
}

// This routine loops forever
void loop()
{
  digitalWrite(a, HIGH);
  digitalWrite(abrake, LOW);
  analogWrite(aspeed, 225);
}

My wiring :

Wiring More wiring

Is this way even possible? Am i doing something wrong? Is there an easier solution?


Solution

  • AnalogWrite to a Digital Pin will only work on D0 and D1 since they have PWM capabilities only. I am guessing it is just ignoring the analog write. Get out the old meter and check.

    Here is a link to their super helpful docs.

    http://docs.spark.io/hardware/#spark-core-datasheet-pins-and-i-o