this is probably a beginners question (I did not go to school for this), but it is stalling me for two days now.
I am writing a sketch in Arduino to move a robot. I store my positions in an array like
int joint1[180];
I got it perfectly working and running if everything is in the robot.ino, but now I want to put this array in a home-made library stringer.h
and stringer.cpp
but acces it from the .ino to make it a little easier to understand for someone else.
the question redefined i readout a home made jcode from sd in the form of a string i put the values to a int whit the toint comand then i store this value in 7 arrays joint1[180] joint2[180] etc now i want to use the array in my main script robot.ino how do i acces the array whitin stringer.ccp or do i put the arrays in my .ino file and make stringer send a string to robot.ino and devide it there ..... this makes it realy hard for the other functions in stringer ????
test situation globals.h
//#include "Arduino.h"
//#include "StandardCplusplus.h"
//#include <vector>
#include "globals.h"
extern int Joint1[180];
extern int Joint2[180];
extern int Joint3[180];
extern int Joint4[180];
extern int Joint5[180];
extern int Joint6[180];
extern int Slomo[180];
globals.cpp
//#include "Arduino.h"
//#include "StandardCplusplus.h"
//#include <vector>
#include "globals.h"
int Joint1[180];
int Joint2[180];
int Joint3[180];
int Joint4[180];
int Joint5[180];
int Joint6[180];
int Slomo[180];
tester.ino
//#include "StandardCplusplus.h"
#include <globals.h>
int check = 100;
int temp = 0;
void setup() {
for (int p = 0;p < check; p++){
Joint1[p] = p + 33;}
}
void loop() {
if (temp < check){Serial.println(Joint1[temp]);temp = temp + 1;}
}
the other way
globals.h
#include "Arduino.h"
#include "StandardCplusplus.h"
#include <vector>
#include "globals.h"
extern std::vector<int> Joint1;
extern std::vector<int> Joint2;
extern std::vector<int> Joint3;
extern std::vector<int> Joint4;
extern std::vector<int> Joint5;
extern std::vector<int> Joint6;
extern std::vector<int> Slomo;
globals.cpp
#include "Arduino.h"
#include "StandardCplusplus.h"
#include <vector>
#include "globals.h"
std::vector<int> Joint1(180);
std::vector<int> Joint2(180);
std::vector<int> Joint3(180);
std::vector<int> Joint4(180);
std::vector<int> Joint5(180);
std::vector<int> Joint6(180);
std::vector<int> Slomo(180);
i wil get a error: #include nested too deeply