[Project 15] – 5 Flex/Bend Sensor + 5 Servo Motor + Arduino

In this project we will control 5 servo motor using 5 flex/bend sensor with Arduino.  I will use arduino uno in the circuit design program. I use usually arduino mega 2560. You can use the other arduino cards. Good Luck.

Circuit:


[Project 15] - 5 Flex- Bend Sensor + 5 Servo Motor + Arduino12

Materials:


Arduino Uno / Mega   x 1
Breadboard   x 1
Servo Motor    x 5
22 Kohm resistor   x 5
Flex/Bend Sensor    x 5
Jumper Cable

 

Program:

//  letsarduino.com
//  [Project 15] - 5 Flex/Bend Sensor + 5 Servo Motor + Arduino
#include <Servo.h>     
 
Servo servoMotor1;      
Servo servoMotor2;
Servo servoMotor3;
Servo servoMotor4;
Servo servoMotor5;

int servoPin1 = 2;      
int servoPin2 = 3; 
int servoPin3 = 4; 
int servoPin4 = 5; 
int servoPin5 = 6; 

void setup() {
  
  servoMotor1.attach(servoPin1);  
  servoMotor2.attach(servoPin2);
  servoMotor3.attach(servoPin3);
  servoMotor4.attach(servoPin4);
  servoMotor5.attach(servoPin5);

} 
 
void loop()
{

  int analogValue = analogRead(A0); 
  int servoAngle = map(analogValue, 550, 640, 0, 179);
  servoMotor1.write(servoAngle);

  int analogValue2 = analogRead(A1); 
  int servoAngle2 = map(analogValue2, 550, 640, 0, 179);
  servoMotor2.write(servoAngle2);

  int analogValue3 = analogRead(A2); 
  int servoAngle3 = map(analogValue3, 550, 640, 0, 179);
  servoMotor3.write(servoAngle3);

  int analogValue4 = analogRead(A3); 
  int servoAngle4 = map(analogValue4, 550, 640, 0, 179);
  servoMotor4.write(servoAngle4);
 
  int analogValue5 = analogRead(A4); 
  int servoAngle5 = map(analogValue5, 550, 640, 0, 179);
  servoMotor5.write(servoAngle5);

}


 

Project Related Images:


[Project 15] - 5 Flex- Bend Sensor + 5 Servo Motor + Arduino12234[Project 15] - 5 Flex- Bend Sensor + 5 Servo Motor + Arduino126



 

You may also like...