This circuit is designed to control multiple servo motors using an Arduino UNO microcontroller. The Arduino UNO provides power to the servos and sends pulse width modulation (PWM) signals to control the position of the servo arms. The circuit includes six servo motors, each connected to the Arduino UNO for both power and control signals. The embedded code on the Arduino UNO reads analog inputs, maps them to servo positions, and writes the corresponding angles to the servos in a sequential manner.
#include <Servo.h>
// Ligamentos (sensores flexibles)
int L01;
int L02;
int L03;
int L04;
int L05;
// Ángulos (grados del sensor)
int ang01;
int ang02;
int ang03;
int ang04;
int ang05;
// Servos (izquierda a derecha en el circuito)
Servo menique;
Servo anular;
Servo medio;
Servo indice;
Servo pulgar;
void setup()
{
// Pines PWM como salida
Serial.begin(9600);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
}
void loop()
{
menique.attach(10);
anular.attach(11);
medio.attach(7);
indice.attach(6);
pulgar.attach(5);
ang01 = analogRead(10);
L01 = map(ang01, 767, 964, 0, 270);
ang02 = analogRead(11);
L02 = map(ang02, 767, 964, 0, 180);
ang03 = analogRead(7);
L03 = map(ang03, 767, 964, 0, 180);
ang04 = analogRead(6);
L04 = map(ang04, 767, 964, 0, 180);
ang05 = analogRead(5);
L05 = map(ang05, 767, 964, 0, 180);
delay(2000);
menique.write(L01);
delay(2000);
anular.write(L02);
delay(2000);
medio.write(L03);
delay(2000);
indice.write(L04);
delay(2000);
pulgar.write(L05);
delay(2000);
}
Filename: sketch.ino
Description: This code initializes five servo objects and attaches them to the corresponding PWM pins on the Arduino UNO. It reads analog values from the same pins (which is likely an error in the code, as analogRead should be used on analog input pins, not PWM output pins), maps these values to a range suitable for servo control, and then writes the mapped values to the servos to set their positions. The servos are actuated sequentially with a delay between each actuation.