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×Official Arduino Uno
1×Alternatively, DIYables ATMEGA328P Development Board
1×USB 2.0 cable type A/B
1×Servo Motor
1×Jumper Wires
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables .

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