The code should be able to handle 3 electrodes for R, G and B. Didn't test it so far (need 2 other electrodes).
Computed value could be outside range [0, 255]. Now, it won't.