# wave moving down line of servos

Hey - I’m having trouble figuring out how to get servos to undulate - What I’d like is an index of values that will propagate through a line of servos, to create an undulation effect (I’m making a robotic snake). I’m having loads of trouble getting this to happen . I want control of the speed of the propagation and if possible, the timing delay from one to another, from outside input.

I have a class called servoWave

constructor: ServoWave::ServoWave(int _numServos, float _angle, unsigned long _period, int _wavelength, int _ampMax){

the number of servos is the total number of servos in the body, the angle is the angle the servo should be written at, the period corresponds to the delay period, the wavelength corresponds to the number of servos until the value is reset to 0, and the ampMax is the total amplitude that the servos will be at.

So I have an index of values that I’m writing the wave to be:

when I’m printing out the angles for each servo, I’m just getting 90 for wave , and my angle equals 0, instead of a whole array of values that are undulating.
I’m not sure what I’m doing wrong, any help would be appreciated
#include “servoWave.h”
//constructor with argiuments about the wave
ServoWave::ServoWave() {
}
ServoWave::~ServoWave() {

• delete servoPositions;*
• delete servos;*
}
ServoWave::ServoWave(int _numServos, float _angle, unsigned long _period, int _wavelength, int _ampMax){
• numServos = _numServos;//servos of the whole unit*
• angle = _angle;//height of wave*
• period = _period; //in milliseconds*
• wavelength = _wavelength;//how many servos long the wave will be*
• ampMax=_ampMax;*
float p = 0;
• int total = int(TWO_PI/0.01);//total num of index pioints, until the amplitude is back at zero*
• int numServos = _numServos;*
• //set currentServo to 0*
• int currentServo = 0;*
• int lastPosition=-1;*
• int steps = 5;*
• long previousMillis = 0;*
• long lastUpdatedAt = millis();*
• float wave[total];*
• p = 0;*
• //initialize servoPosition array*
• for(int i=0;i<numServos;i++){//wtf*
_ servoPositions = 90; // starting position for all servos. could be passed as an argument_
* }*
}
* servos[currentServo]=servo;*
* currentServo++;*
}
* servos[currentServo]=servo;*
* servoPositions[currentServo] = startingPosition;*
* currentServo++;*
}
void ServoWave::update(){

for(int i=0;i<total;i++){
wave = map(sin(p), -1,1,0,180);
p+=0.05;//THIS IS WHA T NMUST INFLUENCE SPEED
Serial.println(wave*);*
}
for(int i=0;i<numServos;i++){
index = i*2;//CHANGE THIS FOR CHANGING THE DIFFERENCE BETEWWEEN THEM
}
}
void ServoWave::move(){
for(int i=0;i<numServos;i++){
angle = wave[index*];*
index = (index*+1)%total;*
Serial.println(angle);
}
}
int ServoWave::calculateAngle(){
}
void ServoWave::passDownValues(int firstValue){

}
{"ft_lang_label":"__label__en","ft_lang_prob":0.5498633,"math_prob":0.9665418,"size":2937,"snap":"2021-43-2021-49","text_gpt3_token_len":836,"char_repetition_ratio":0.15138084,"word_repetition_ratio":0.037037037,"special_character_ratio":0.28021792,"punctuation_ratio":0.18050541,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9967899,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-28T05:52:07Z\",\"WARC-Record-ID\":\"<urn:uuid:7bad87aa-dab9-44dc-b32f-c86d174c593d>\",\"Content-Length\":\"21475\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b56cd0ab-dc52-42a5-8a0d-c2664751a49c>\",\"WARC-Concurrent-To\":\"<urn:uuid:7ab28e26-1461-4258-8dfe-46db0db11a88>\",\"WARC-IP-Address\":\"184.104.202.141\",\"WARC-Target-URI\":\"https://forum.arduino.cc/t/wave-moving-down-line-of-servos/91321\",\"WARC-Payload-Digest\":\"sha1:CNXARU3YA45JXXEOZPCBRGQZ3XFLQ4SA\",\"WARC-Block-Digest\":\"sha1:QVZONFQOYF26KGN3YEXUDFFWU2VA6UXP\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323588257.34_warc_CC-MAIN-20211028034828-20211028064828-00267.warc.gz\"}"}