I'm trying to use the number that is mapped from the sensor to make the servo move to its angle.
The code compiles cleanly, but the servo will not move.
#include <Servo.h>
int Finger1 = 0;
int Finger2 = 1;
int Finger3 = 2;
int Finger4 = 3;
int Finger5 = 4;
Servo myservo;
void setup()
{
Serial.begin(9600);
myservo.attach(2);
}
void loop()
{
byte servoValue1;
byte servoValue2;
byte servoValue3;
byte servoValue4;
byte servoValue5;
int FingerV1 = analogRead(Finger1);
int FingerV2 = analogRead(Finger2);
int FingerV3 = analogRead(Finger3);
int FingerV4 = analogRead(Finger4);
int FingerV5 = analogRead(Finger5);
if (FingerV1 < 0) FingerV1 = 0;
else if (FingerV1 > 70) FingerV1 = 70;
if (FingerV2 < 0) FingerV2 = 200;
else if (FingerV2 > 70) FingerV2 = 70;
if (FingerV3 < 0) FingerV3 = 200;
else if (FingerV3 > 70) FingerV3 = 70;
if (FingerV4 < 0) FingerV4 = 200;
else if (FingerV4 > 70) FingerV4 = 70;
if (FingerV5 < 0) FingerV5 = 200;
else if (FingerV5 > 70) FingerV5 = 70;
byte servoVal1 = map(FingerV1,70, 0, 255, 0);
byte servoVal2 = map(FingerV2,70, 0, 255, 0);
byte servoVal3 = map(FingerV3,70, 0, 255, 0);
byte servoVal4 = map(FingerV4,70, 0, 255, 0);
byte servoVal5 = map(FingerV5,70, 0, 255, 0);
Serial.print(servoVal1);
Serial.print(servoVal2);
Serial.print(servoVal3);
Serial.print(servoVal4);
Serial.print(servoVal5);
myservo.write(servoVal1);
delay(100);
}
Moderator edit: CODE TAGS. Why is it so hard?