Page 58 - MDP2020-1
P. 58
| 인천전자마이스터고등학교 ·············································································································
52
{
readPot();
temp = SensVal[3];
if (temp < 0) temp = 0;
temp = map(temp, 0, 680, 0 ,6);
verz = Delay[temp];
}
void readPot()
{
SensVal[0] = analogRead(sensorPin0);
SensVal[1] = analogRead(sensorPin1);
SensVal[2] = analogRead(sensorPin2) - 160;
SensVal[3] = analogRead(sensorPin3);
}
void mapping()
{
ist[0] = map(SensVal[0], 150, 900, 600, 2400);
ist[1] = map(SensVal[1], 150, 900, 600, 2400);
ist[2] = map(SensVal[2], 150, 900, 600, 2400);
ist[3] = map(SensVal[3], 150, 900, 600, 2400);
}
void record()
{
joint0[arrayStep] = ist[0];
joint1[arrayStep] = ist[1];
joint2[arrayStep] = ist[2];
joint3[arrayStep] = ist[3];
}
void Read()
{
sol[0] = joint0[arrayStep];
sol[1] = joint1[arrayStep];
sol[2] = joint2[arrayStep];
sol[3] = joint3[arrayStep];
}
void move_servo()
{
servo_0.writeMicroseconds(ist[3]);
servo_1.writeMicroseconds(ist[2]);
servo_2.writeMicroseconds(ist[0]);