Go Down

Topic: MKR Motor Carrier and Servo (Read 94 times) previous topic - next topic

apagliari

Trying to so something really simple.

1 servo connected to Arduino MKR Motor Carrier
1 Arduino Motor carrier
1 Arduino MKR Wifi 1010
<MKRMotorCarrier.h> library in place
official sketch "Servo_test"

No move from the Servo. Same Servo perfectly working wired to an Arduino Uno Wifi with the official sketch "Sweep"

Here below the code.

Attached an image of the wiring.

Any help really appreciated.

Andrea

Code: [Select]

#include <MKRMotorCarrier.h>
#define INTERRUPT_PIN 6

//Variable to store the battery voltage
int batteryVoltage;

void setup()
{
  //Serial port initialization
  Serial.begin(9600);
  while (!Serial);

  //Establishing the communication with the motor shield
  if (controller.begin())
    {
      Serial.print("MKR Motor Shield connected, firmware version ");
      Serial.println(controller.getFWVersion());
    }
  else
    {
      Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch");
      while (1);
    }

  // Reboot the motor controller; brings every value back to default
  Serial.println("reboot");
  controller.reboot();
  delay(500);

  //Take the battery status
  float batteryVoltage = (float)battery.getConverted();
  Serial.print("Battery voltage: ");
  Serial.print(batteryVoltage);
  Serial.print("V, Raw ");
  Serial.println(battery.getRaw());
}


void loop() {

  //Take the battery status
  float batteryVoltage = (float)battery.getConverted();

  //Reset to the default values if the battery level is lower than 11V
  if (batteryVoltage < 5)
  {
    Serial.println(" ");
    Serial.println("WARNING: LOW BATTERY");
    Serial.println("ALL SYSTEMS DOWN");
    while (batteryVoltage < 5) {
      batteryVoltage = (float)battery.getConverted();
    }
  }
  else
  {
    //Servo sweep from 0 position to 180
    for (int i=0; i<180; i+=5)
    {
      //Choose what of all the servo connectors do you want to use: servo1(default), servo2, servo3 or servo4
      servo2.setAngle(i);
      Serial.print("Servo position");
      Serial.println(i);
      delay(50);
    }
   
    delay(200);
   
    //Servo sweep from 180 position to 0
    for (int i=180; i>0; i-=5)
    {
      //Choose what of all the servo connectors do you want to use: servo1(default), servo2, servo3 or servo4
      servo2.setAngle(i);
      Serial.print("Servo position");
      Serial.println(i);
      delay(50);
    }
  }

  //Keep active the communication MKR1000 & MKRMotorCarrier
  //Ping the samd11
  controller.ping();
  //wait
  delay(50);
}

jojobaa

Hi, make sure you have updated the firmware of the motor carrier using the flasher sketch. After uploading the sketch open serial monitor and wait till the message completes giving you the latest firmware version.
┗(•ˇ_ˇ•)―→ Member of the Arduino customer service team
( ━☞´◔‿ゝ◔`)━☞ Contact us through https://bit.ly/2xxu1le

Go Up