Jump to content

help with arduino

hambobolubia

Hello I am writing an arduino sketch and would like to set an array equal to another array based on a variable if that make any sense....

i have an analog read thats reading an array of 3 inputs and i want to set that equal to another array but based on a counter

 

here are  may arrays


const int SliderPin[3] = {14,15,16};

int CurrentProfile = 0;

int Profile_0[3]={0,0,0};
int Profile_1[3]={0,0,0};
int Profile_2[3]={0,0,0};
int Profile_3[3]={0,0,0};

 

 

and here is the code i have so far

 


  if (CurrentProfile > 3) {
    CurrentProfile = 0;
    };
  analogRead(SliderPin) = Profile_(CurrentProfile);

 

hopfully you can see what i want to do im trying to make the program as small as possible so i can port it to cheeper (and smaller) chips as the rest of the code is quite lengthy

Link to comment
Share on other sites

Link to post
Share on other sites

  if (CurrentProfile > 3) {
    CurrentProfile = 0;
    };
  analogRead(SliderPin) = Profile_ + CurrentProfile;

This should do the trick, I don't have the means to test it right now :)

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

i tried that and i get 

 


'Profile_' was not declared in this scope

could i have an array of arrays? does that make sense?

Link to comment
Share on other sites

Link to post
Share on other sites

That's called a jagged array (or multidemensional), and it's possible, yes

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, myselfolli said:

That's called a jagged array (or multidemensional), and it's possible, yes

but do the lower end atmegas/atinys support it? and do you think that would be a easier option? 

Link to comment
Share on other sites

Link to post
Share on other sites

They should support it alright. As for ease of use: the other option obviously isn't working for you, so do you really have a choice? xD

 

I'll go look some stuff up, brb

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, myselfolli said:

They should support it alright. As for ease of use: the other option obviously isn't working for you, so do you really have a choice? xD

 

I'll go look some stuff up, brb

im doing the same time for reading (woot!)

Link to comment
Share on other sites

Link to post
Share on other sites

ok so this is what iv come up with so far still dosent work but i thing im making progress

 

Vars



int CurrentProfile = 0;

int Profile[4][3]={
  {0,0,0},
  {0,0,0},
  {0,0,0},
  {0,0,0}
  };

 

and program


  if (CurrentProfile > 3) {
    CurrentProfile = 0;
    };
  analogRead(SliderPin) = Profile[CurrentProfile];

 

hopefull its just a syntax thing but heres my error


lvalue required as left operand of assignment

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×