Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled Multi-Servo System with Flex Sensors

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Multi-Servo System with Flex Sensors

Circuit Documentation

Summary of the Circuit

This circuit is designed to control multiple servo motors using flex sensors. The flex sensors are connected to the analog pins of an Arduino UNO microcontroller, which reads the deflection of the sensors and maps them to the rotation angles of the servo motors. The servo motors are connected to the digital pins of the Arduino UNO. The circuit is powered through the Arduino UNO, which distributes power to the servo motors and the flex sensors.

Component List

Microcontroller

Servo Motors

Flex Sensors

Resistors

Wiring Details

Arduino UNO

Servo Motors

Flex Sensors

Resistors (10k Ohms)

Documented Code

/*
 * Arduino Sketch for Flex Sensors Controlling Servo Motors
 *
 * This code reads the values from multiple flex sensors connected to the analog
 * pins of the Arduino UNO and controls the corresponding servo motors connected
 * to the digital pins. The flex sensor deflection is mapped to the rotation
 * angle of the servo motors.
 */

#include <Servo.h>

// Define servo objects
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;

// Define analog pins for flex sensors
const int flexSensor1 = A0;
const int flexSensor2 = A1;
const int flexSensor3 = A2;
const int flexSensor4 = A3;
const int flexSensor5 = A4;

// Define digital pins for servos
const int servoPin1 = 2;
const int servoPin2 = 3;
const int servoPin3 = 4;
const int servoPin4 = 5;
const int servoPin5 = 6;

void setup() {
  // Attach servos to their respective pins
  servo1.attach(servoPin1);
  servo2.attach(servoPin2);
  servo3.attach(servoPin3);
  servo4.attach(servoPin4);
  servo5.attach(servoPin5);
}

void loop() {
  // Read flex sensor values
  int flexValue1 = analogRead(flexSensor1);
  int flexValue2 = analogRead(flexSensor2);
  int flexValue3 = analogRead(flexSensor3);
  int flexValue4 = analogRead(flexSensor4);
  int flexValue5 = analogRead(flexSensor5);

  // Map flex sensor values to servo angles (0-180 degrees)
  int angle1 = map(flexValue1, 0, 1023, 0, 180);
  int angle2 = map(flexValue2, 0, 1023, 0, 180);
  int angle3 = map(flexValue3, 0, 1023, 0, 180);
  int angle4 = map(flexValue4, 0, 1023, 0, 180);
  int angle5 = map(flexValue5, 0, 1023, 0, 180);

  // Write angles to servos
  servo1.write(angle1);
  servo2.write(angle2);
  servo3.write(angle3);
  servo4.write(angle4);
  servo5.write(angle5);

  // Small delay to allow servos to reach the position
  delay(15);
}

This code is saved as sketch.ino and is intended to be uploaded to the Arduino UNO microcontroller. It initializes the servo objects, defines the pin connections, and contains the main logic for reading the flex sensor values and controlling the servo motors.