Constrain Function Error

Hi, guys. I'm trying to use the constrain function but i'm getting an error
Here's my code

constrain(vol[0], 0, 127);  //vol is a byte type variable

and the error i'm getting

C:\Users\Tomas\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\cores\arduino/Arduino.h:95:39: error: expected ')' before '<' token

 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

                                       ^

c:\ProgramData\Arduino - VSCode\MML_TomasSasovsky\MML_TomasSasovsky.ino:94:1: note: in expansion of macro 'constrain'

 constrain(vol[TR1], 0, 127);

 ^~~~~~~~~

Somewhere in the code you didn't post you have more ( than you have ).

You don't show how 'vol' is defined.
You don't show how TR1 is defined.

Hi,
The constrain is used like this;

sensVal = constrain(sensVal, 10, 150);  // limits range of sensor values to between 10 and 150

Tom... :slight_smile: