Go Down

Topic: Control delay between array index numbers? (Read 2137 times) previous topic - next topic


Mar 01, 2011, 09:26 pm Last Edit: Mar 01, 2011, 09:56 pm by ingi Reason: 1
Hello, I am making a small code for arduino where I controle servos with array. What I am trying to find out is to control how long it will take myservo 1 for example to travel from index 2 to 3.  I would like to do that with int del1. If you could point me tovards some answere would be great.
Hope this makes sence



Code: [Select]
#include <Servo.h>

Servo myservo1;
Servo myservo2; 

int serv1[] = {10, 10, 20, 20, 10};
int serv2[] = {10, 20, 20, 10, 10};
int del1[] = {10, 10, 20, 20, 10}; // i imagien i would use this to contol different "delays".

int pos ;
int pause = 150;
int times = 4;
void setup()

void loop()
  for(int i=0; i<times; i=i+1)
myservo1.write(serv1[i]); // here i would try to control how fast it will jump from one stepp to the other (one index to another in "myserv1 and 2", //preferably as a array also.




The forum software does not like the string of characters [ i ] in quotes or plain text. It thinks they are a tag to start displaying italics. Please modify your post, to delete the code. Press the # button above the text entry block, and paste your code again.

As it is, it is impossible to tell what that code is supposed to be doing.
The art of getting good answers lies in asking good questions.


Yes, that is much better. Replace the value that is in the () after for the delay statement with the del1 array element:
Code: [Select]
The art of getting good answers lies in asking good questions.

Go Up