Please help me add analogreference(internal1v1)

It must be very simple , but i am not into programming so i need a little help

This is a working sketch
Can someone tell me where to add : analogReference(INTERNAL1V1)

//***Analogue Setup
byte AnalogPinArray[15] = {0};
int AnalogueDelay[(sizeof(AnalogPinArray) / sizeof(AnalogPinArray[0]))] = {0};
word AnalogueInvert = 0;
byte NoOfAnalogPins =0;
int AnalogStateArray[(sizeof(AnalogPinArray) / sizeof(AnalogPinArray[0]))];
unsigned long PrevAnalogeMillis[sizeof(AnalogPinArray) / sizeof(AnalogPinArray[0])];

void AnalogueCheck(){
int pinread;
for (count=0;count<NoOfAnalogPins;count++) {
if(millis() - PrevAnalogeMillis[count] > AnalogueDelay[count]) {
PrevAnalogeMillis[count] = millis();
pinread = analogRead(AnalogPinArray[count]);
if (AnalogStateArray[count] != pinread && WaitForAck == false){
AnalogStateArray[count] = pinread;
Send(BoardAdd);
Send(" A “);
Send(count+1);
Send(” ");
if (bitRead(AnalogueInvert,count) == 1){
Send(map(AnalogStateArray[count], 0, 1023, 1023, 0));
Send();
WaitForAck == true;
}
else{
Send(AnalogStateArray[count]);
Send();
WaitForAck == true;
}
}
}
}
}

             WaitForAck == true;

That’s not so good.


Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the “Code” icon above the posting area. It is the first icon, with the symbol: </>


Can someone tell me where to add : analogReference(INTERNAL1V1)

In setup? Before you do your first analogRead.

I believe analogreference(internal1v1) only works on certain boards like the mega. I may be wrong but worth checking

True, but he might have a Mega.

Why do you think you should use analogreference(internal1v1) ?
Please describe your setup and application.

“byte AnalogPinArray[15]” suggests that this is indeed the case.

You can put analogReference() anywhere you like as long as it is before the relevant analogRead(). And you can change the reference between analogRead()s if necessary. You should probably discard the first reading after a change of the reference value.
Use Internal for an Uno and Internal1v1 for a Mega.

...R