Hi,
In my code, I am defining the following function before the main void loop(). While compiling, it is giving me an error for the first line of below code saying
"a function-definition is not allowed here before '{' token"
Any idea, why its happening and how to fix it?
void process(int s[], int sizeofarray, int i) {
g1=LOW ; // turn off green LED for 1st bin pick
w[i]=LOW ; // turn off white LED for picked bin
if (i==(n-1)) // if bin picked is last one
{ g1=HIGH ; // kit is complete as this is the last item
count = count + 1 ; // increment count by 1
w[0]=HIGH ; // turn on white LED for first bin
}
else // for bins other than last
w[i+1]=HIGH ; // turn on white LED for next bin
}
And btw, I have defined another function by a different name in exactly the same manner above this which doesn't give an error while compiling.
FYI, this function is saying once an item is picked from a bin, turn off the LED for this bin and turn on LED for next bin. If its last bin, then increment count by one and turn on first bin's LED.
Entire code attached.
Regards.
sketch_apr03a.ino (2 Bytes)
Two_Bin_Trial_w_Function_Rev002.cpp (3.95 KB)