Bug Filed on 08-29-2016: Arduino Uno Servo Motor Test

Using the Browser for Arduino Uno

When adding Devices/Widgets > Actuators > Motors > Servo Motor

I cannot choose Digital as the interface and assign pin D9 for PWM as the widget is a slider.

Using Custom Widget the slider can only turn on or off the device. PWM is not actually usable.

Is this the only case or are there any others. Used an oscilloscope to test with. using a W5100 Ethernet Shield.

Error message
Please fix the following errors:


Failed to add the widget, please re-check your settings.

1 Like

Welcome to Cayenne!

PWM is actually analog. Try changing to analog and let us know if it works.

yes, hi.

PWM is digital if i remembered correctly. It uses Duty cycle and TTL logic. I did try with analog interface and virtual, neither works.

I have the same problem.
Did you solve it?

1 Like

nope, i gave up.

Didn’t have time to check it.

Will look into tomorrow and let you know.

@leolozer @thushanth,

Are you both using the provided sketch file from the “Step 1: Sketch File” button? If so, make note of this section

#define SERVO_VIRTUAL_PIN 1
#define SERVO_DIGITAL_PIN 9

Make sure that SERVO_DIGITAL_PIN is set to the PWM pin you wired the servo to on your Arduino (in my case here, 9). Then make note of what SERVO_VIRTUAL_PIN is set to.

Once the sketch is uploaded to your Arduino, try creating the widget again from Devices/Widgets > Actuators > Motors > Servo Motor , but this time set the Connectivity to ‘Virtual’ and the Pin to the number set for SERVO_VIRTUAL_PIN (in my case, 1).

That should allow you to add the widget to the dashboard without error and control your servo.

1 Like

I have the same problem. My code seems right from what I read above, but I am still getting the error message. I have tried to put in different numbers and values everywhere, but nothing seems to work.
My servo is in digital pin 6.

  #define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

    // If you're not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples.
    #include <CayenneEthernetW5500.h>

    #define SERVO_VIRTUAL_PIN 2
    #define SERVO_DIGITAL_PIN 6

    // servo util lib
    #include <Servo.h>
    Servo s1;

    // a flag to keep track of servos last position
    double lastPosition = 0;

    // Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
    char token[] = "private_token";

    void setup()
    {
      Serial.begin(9600);
      Cayenne.begin(token);

      s1.attach(SERVO_DIGITAL_PIN);
    }

    CAYENNE_IN(SERVO_VIRTUAL_PIN)
    {
      // get value sent from dashboard
      double currentValue = getValue.asDouble();
      int position = currentValue * 200;
      // actually move the servo to the specified position
      s1.write(position);

      //update last position
      lastPosition = currentValue;
    }

    void loop()
    {
      Cayenne.run();
    }

@bpelson

I can see in the bottom screenshot that you have your ‘Connectivity’ set to Analog. Have you tried setting it to ‘Virtual’ with Pin V2? I suspect that will allow you to add and then control the servo at physical pin D6 per your sketch.

1 Like

Also I edited your post to remove the Cayenne token so no one sees it here and tries to pass data to that Arduino entry on your account :slight_smile:

Thank you so much! That seemed to do the job! Also, good catch there with the token :slight_smile:

hello

sory i have one more question. It work but just 0 and 1 position.( left or right)
i woud like to control stepper motor from -45 to 45 with slider ?
how i control angle ?
can help me ?

From what I saw in the post up above it should do what you want. Did you add the widget as a slider type?