Grabber

Andere Bibliotheken:
Grabber
Motor
Pivot
Twister
Abstandssensor
Lichtsensor

Each module (with the powerbrain as an exception) is assigned a specific color by the powerbrain. Connecting an arduino-powerbrain (!) via USB cable to a PC activates the colors on all connected modules. Use these to initialize the objects in your sketches correctly.

E.g. after plugging in the USB cable, a connected Motor lights up a purple LED. You will have to initialize this motor in the sketch with "TBMotor variableMotorName(PURPLE);"

Arduino Bibliothek Pivot



    The Pivot gives your creations joints. With these you can construct arms or legs with ease. The module can turn in a range from 0° to 180°.  Additionally,  the module can give you the current angle as feedback - this way,  you can use the Pivot module e. g.  as a lever.


    Sometimes you want to interact with your Pivot, you will experience it will try to hold it's current position.  To deactivate this behavior look at stop() .

Function Overview

Function Description


    Name

        TBPivot()

    Description

        Instance a Module from Type Pivot. It is neccessary to include the header file.
        #include "TBPivot.h"

    Syntax

        TBPivot(color);
        TBPivot(color,invert);

    Parameter

        color: Color of the module which is shown during setup.
                Values: RED, GREEN, BLUE, MINT, PURPLE, YELLOW, WHITE

       invert (optional): Flag for inverting rotation direction.
                Values: 0 - Not inverting
                             1 - Inverting

    Return

        None

    Example


     
        #include "TBPivot.h" // include pivot library
       
        TBPivot pivot(RED); // instance of a pivot
        byte pos = 0;
        byte direction = 0;

        void setup()
        {
            pivot.setPosition(90); // move pivot to the middle and hold
            direction = 1;
        }

        void loop()
        {
            /* receive the current postion */
            pos = pivot.getPosition();

            if (pos == 180) direction = 0;
            if (pos == 0) direction = 1;

            if (direction == 1)
                pivot.setPosition(++pos, 30); // move with 30 percent of the speed
            if (direction == 0)
                pivot.setPosition(--pos, 30); // move with 30 percent of the speed
        }


    Name

        setPosition()

    Description

        Call this function to move and hold a position of the Pivot.

    Syntax

        setPosition(angle);
        setPosition(angle, speed);

    Parameter

       angle: Position which the Pivot should hold.
               Value: 0 - 180 (degree)
      speed:
Movement speed to reach the position.
                Value: 0 - 100 (in percent)

    Return

        None

    Example


       
        #include "TBPivot.h" // include pivot library
       
        TBPivot pivot(RED); // instance of a pivot
        byte pos = 0;
        byte direction = 0;

        void setup()
        {
            pivot.setPosition(90); // move pivot to the middle and hold
            direction = 1;
        }

        void loop()
        {
            /* receive the current postion */
            pos = pivot.getPosition();

            if (pos == 180) direction = 0;
            if (pos == 0) direction = 1;

            if (direction == 1)
                pivot.setPosition(++pos, 30); // move with 30 percent of the speed
            if (direction == 0)
                pivot.setPosition(--pos, 30); // move with 30 percent of the speed
        }



    Name

        getPosition()

    Description

        Call this function to receive the current position of the Pivot.

    Syntax

        getPosition();

    Parameter

       None

    Return

        byte value between 0 - 180

    Example


          
        #include "TBPivot.h" // include pivot library
       
        TBPivot pivot(RED); // instance of a pivot
        byte pos = 0;
        byte direction = 0;

        void setup()
        {
            pivot.setPosition(90); // move pivot to the middle and hold
            direction = 1;
        }

        void loop()
        {
            /* receive the current postion */
            pos = pivot.getPosition();

            if (pos == 180) direction = 0;
            if (pos == 0) direction = 1;

            if (direction == 1)
                pivot.setPosition(++pos, 30); // move with 30 percent of the speed
            if (direction == 0)
                pivot.setPosition(--pos, 30); // move with 30 percent of the speed
        }



    Name

        stop()

    Description

        Stops a moving action and disable the position hold. This is especially useful, if you want to move the Pivot by hand.

    Syntax

        stop()

    Parameter

        None

    Return

        None

    Example


     
       #include "TBPivot.h" // include pivot library

       TBPivot motor(BLUE); // instance of a pivot
       
       setup()
       {
          /* We want to log data later in this sketch */
          Serial.begin(9600);

           /* Move the Pivot to a specific position */
          pivot.setPosition(90);
          delay(1000);

          pivot.stop();   //disable position hold
          /* You can now move the Pivot freely */
        }

       void loop()
       {
            /* Move the Pivot and look at the output on the Serial Console/Serial Plot*/
            Serial.write(pivot.getPosition());
       }



    Name

        enablePowerCut()

    Description

        This function enables the current limiter in the module. It is only used to revert the effect of disablePowerCut().

    Syntax

        enablePowerCut();

    Parameter

       None

    Return

        None

    Example


     
       #include "TBPivot.h" // include pivot library

       TBPivot pivot(BLUE); // instance of a pivot
       
       setup()
       {}

       void loop()
       {
           /* Try to use a Pivot with many modules attached->stops and blinks purple */
           pivot.setPosition(130);
           delay(2000);

           /* Retry without current limiter */            
           pivot.disablePowerCut();
           pivot.setPosition(130);
           delay(2000);

           /* Try to always reactivate the current limiter afterwards */
           pivot.enablePowerCut();

       }



    Name

        disablePowerCut()

    Description

        The current limiter can be deactivated with this function. Heavy loads stop the module to protect it from permanent damage. In some cases, this limits the possibilities. If you are sure what you are doing, you can disable this feature to get a pinch more power. Remember to reactivate the limiter using enablePowerCut().

       Warning: Driving the Pivot with disabled current limiter may reduce the lifetime of your module.

    Syntax

        disablePowerCut();

    Parameter

       None

    Return

        None

    Example


         
        #include "TBPivot.h" // include pivot library

       TBPivot pivot(BLUE); // instance of a pivot
       
       setup()
       {}

       void loop()
       {
           /* Try to use a Pivot with many modules attached->stops and blinks purple */
           pivot.setPosition(130);
           delay(2000);

           /* Retry without current limiter */            
           pivot.disablePowerCut();
           pivot.setPosition(130);
           delay(2000);

           /* Try to always reactivate the current limiter afterwards */
           pivot.enablePowerCut();

       }