Arduino - Servo.write()

Descripción

Escribe un valor en el servo, controlando el eje en consecuencia. En un servo estándar, esto hará que el ángulo del eje (en grados), mueva el eje para orientarse. En un servo de rotación continua, esto seleccionará la velocidad del servo (siendo 0 a toda velocidad en una dirección, siendo 180 la velocidad máxima en la otra, y un valor de cercano a 90 sin movimiento).

Sintaxis

servo.write(angle)

Parámetros

  • servo: una variable de tipo Servo
  • angle: el valor a escribir en el servo, de 0 a 180

Ejemplo

Hardware Required

1×Arduino UNO or Genuino UNO
1×USB 2.0 cable type A/B
1×Servo Motor
1×Jumper Wires
1×(Optional) 9V Power Adapter for Arduino
1×(Recommended) Screw Terminal Block Shield for Arduino Uno
1×(Optional) Transparent Acrylic Enclosure For Arduino Uno
Please note: These are Amazon affiliate links. If you buy the components through these links, We will get a commission at no extra cost to you. We appreciate it.

Wiring Diagram

Arduino Servo Motor Wiring Diagram

This image is created using Fritzing. Click to enlarge image

Arduino Code

#include <Servo.h> Servo myservo; void setup() { myservo.attach(9); myservo.write(90); // set servo to mid-point } void loop() {}

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit

※ OUR MESSAGES