Reference > Brix for Arduino
|
1.02.001 - Standard Servo Motor
![]()
Description
Brick 1.02.001 is a servo motor that can be positioned between 0° and 180°. The motor can be identified by the symbol of a half gear on the back side;
the symbol represents the capability of the motor to turn 180°.
Specifications
Pinout
The servo motor has a cable with a 3 pin connector:
Example - Wiring
Example - Code
The code below sweeps the motor 3 times between 0° and 180° with 10° steps.
//--------------------------------------------------------------------------------------------------
// demo-1-02-001.ino
//
// Description: Demo to control a 4DBrix 1.02.001 servo motor.
//
// Author: Lowa
// Created: 18-Dec-2016
// Copyright (C) 2016, 4DBrix LLC. All rights reserved.
//
// Please feel free to use this example for personal, non-commercial use only, provided you keep the
// copyright message intact. Have fun !
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Included libraries
//--------------------------------------------------------------------------------------------------
#include <Servo.h>
//--------------------------------------------------------------------------------------------------
// Global variables
//--------------------------------------------------------------------------------------------------
Servo servo; // Object to interface with servo 1
int servoPin; // The control pin for servo 1
//--------------------------------------------------------------------------------------------------
// Initialization process
//--------------------------------------------------------------------------------------------------
void setup() {
// Start the serial communication
Serial.begin(9600); // Use the default Arduino baud rate
// Configure the servo motor
servoPin = 5; // Digital pin 5 will be used for the servo signal
pinMode(servoPin, OUTPUT); // Define pin 5 as output pin
servo.attach(servoPin); // Activate the servo
// Sweep the servo 3 times
for (int i = 0 ; i < 3 ; i++) {
for (int j = 0 ; j < 19 ; j++) {
// Reposition the servo
servo.write(j*10); // Move the servo to the desired position
Serial.print("Angle = "); // Print feedback in the serial monitor
Serial.println(j*10);
// Wait 250 milliseconds before taking the next step
delay(250);
}
// Wait before starting the next sweep
delay(250);
}
// Reposition the servo
servo.write(0); // Return to the 0 position
delay(500);
// Deactivate the servo
servo.detach();
}
//--------------------------------------------------------------------------------------------------
// Processing loop
//--------------------------------------------------------------------------------------------------
void loop() {
}
//--- End-of-File-----------------------------------------------------------------------------------
|

