DIY sysex fader box status and questions.

Peter Korsten peter at severity-one.com
Mon Apr 23 22:39:19 CEST 2012


Op 23-4-2012 22:23, ToAd schreef:

> 1) how do I make a function of this that I can call up in the void loop?
> Something in the line of:
> array calcpotrot(byte switchVar, byte OLDswitchVar) ---(what exactly do
> I need to put between ()?)
> and than change the for loop in void loop to
> potrot1[3] = calcpotrot(switchVar1, OLDswitchVar1)

What do you mean by 'void loop'? And what exactly is your piece of code 
supposed to do?

Those variables, switchVar and OLDswitchVar, what are they? How are they 
defined?

> SHould I end this function with a return statement? Or is it somehow
> defined in the syntax?

You use a return statement if you want to return a value, in C that 
would be a numeric value or a pointer. Do you need to return something, 
to use in an expression?

> Next one, how does one do this:
> oldvalue = value;
> for an entire array with same length?

int index;
for( index = 0; index < length; index++ )
     array[index] = value;

Unless you're copying one array to another, of course.

> Last one, any idea what's wrong with this:
> for (int n = 0; n <= 3; n++)
> {
> int c = OLDvalues1[n];
> int d = encoders1[n];
> values1[n] = c + d;
> values1[n] = OLDvalues1[n];
> }

The 'values1[n] = c + d' statement is useless, because the next 
statement overwrites the value of value1[n].

> I should get me a good book about the basics, i guess :-\

Yeah, that's probably a good idea. C is a pretty simple language, but 
also somewhat primitive and it's easy to shoot yourself in the foot.

- Peter


More information about the music-bar mailing list