Generating a 0-40 ohm signal

MOSFet's have an ohmic range, where careful control of the gate voltage provides nearly linear resistance from source to drain. That converts your problem to generating a variable voltage from an Arduino, which cabe done with PWM.