Assistance with error please


i'm new , experimenting servos using servo.h. version 17 of arduino compiler. i'm trying learn arrays , loops reducing coded lines on repeated tasks. maybe going wrong , ther easier ways, learning now. anyway i'm getting error , not sure why. i've search references have not found anything. because i'm trying nested loops string arrays? not sure what's wrong here. have seen many examples of numeric nested arrays work. , please explain if possible. want learn , understand. not looking person fix it.

error: many initializers 'char []' in function 'void panelopen()':


code: [select]
#include <servo.h>

char domepie[]= {"servod1","servod2","servod3","servod4"};
int pinarray[]= {9, 10, 11, 12, 13};
int pos;       // variable store servo position
int closepos = 10; // panel closed position (in degrees 0-180)
int openpos = 100; // panel full open position
int servostep = 1; // servo stepping in degrees per step
int i;
int count;

void setup()
   {
     for (i=0; 1 < 4; i++)
      {
          servo domepie[i];
          domepie[i].attach(pinarray[i]);
      }
   }

void panelopen()
   {
    for(pos =closepos; pos < openpos; pos += servostep)
     {
     for (count=0;count < 4;count++)
     {
       domepie[i].write(pos);  // cycle through each servo (1-4)       }
     }
     delay(15);  // waits 15ms servo move. higher number slower servo moves
    }
void loop()
   {
    panelopen(); // calling functions now
   }

code: [select]
char domepie[]= {"servod1","servod2","servod3","servod4"};

should read
code: [select]
char* domepie[]= {"servod1","servod2","servod3","servod4"};

this because want array of character pointers (char* []), not array of characters (char []).
it declared
code: [select]
char domepie[][8]= {"servod1","servod2","servod3","servod4"};

however, academic because
code: [select]
servo domepie[i];
          domepie[i].attach(pinarray[i]);
...
domepie[i].write(pos);
won't work. need array of servo objects globally in scope.



this:
code: [select]
for (i=0; 1 < 4; i++)

is going give grief.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Assistance with error please


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums