Robotic arm

Rudra kumar's picture


Joined: Aug 19, 2018

Replies: 0
Robotic arm
August 19, 2018 - 6:46pm

Hi sir, My name is rudra i have red your artical on record and play robotic arm. i could not understood about C_S0_pos, please tell me about that. 

Aswinth Raj's picture


Joined: Aug 16, 2016

Replies: 952
Record and Play Robotic Arm Program explanation
August 20, 2018 - 12:59pm

   if (P_S0_pos == S0_pos) //If 1st and 2nd value are same
    Servo_0.write(S0_pos); //Control the servo
    if (C_S0_pos != S0_pos) //If the POT has been turned 
      saved_data[array_index] = S0_pos + 0; //Save the new position to the array. Zero is added for zeroth motor (for understading purpose)
      array_index++; //Increase the array index 
    C_S0_pos = S0_pos; //Saved the previous value to check if the POT has been turned 

I assume is doubt is with the above snippet of code in the project Record and Play Arduino ARM


We are saving the values of pot in a array called saved_data during record mode. But we should push a value into this array only if the pot value has changed. Else we will save the same in the array again and again. 

So we check if the POT value is different from the previous value and only if it is different the new value is pushed into the array. The previous value is saved in the variable C_S0_pos and the new value will be in S0_pos