1 Usage
viridian edited this page 2024-02-06 17:28:33 +01:00

Usage

Function for Function

Servo my_servo(int,int)

This creates a new instance of a servo the two int are the pins.

begin()

Sets both pins as out and sets them low.

position(int)

Sets the position to one of three values they mean:

0=Neutral position

1=The first non Neutral position

2=The second non Neutral position

Example

#include <lego_servo.h>

Servo my_servo(2,3);
// Creates a new servo called my_servo on pin 2 and 3
void setup() {
  my_servo.begin();
  // Sets the pins to an OUTPUT and LOW
}

void loop()
  my_servo.position(1);
  //  Go to position one
  delay(1000);
  
  my_servo.position(2);
  // Go to position two
  delay(1000);

  my_servo.position(0);
  // Go to neutral position
  delay(1000);
}