// set 3 channels to a RGB value with the specified hue (0...764)
void setChannelRGB(int channel, int hue) {
hue = hue % 765;
if (hue < 256) {
/// blue to red
DMXSerial.write(channel , hue);
DMXSerial.write(channel+1, 0);
DMXSerial.write(channel+2, 255-hue);
} else if (hue < 511) {
/// red to green
DMXSerial.write(channel , 255 - (hue-255));
DMXSerial.write(channel+1, hue-255);
DMXSerial.write(channel+2, 0);
} else {
/// green to blue
DMXSerial.write(channel , 0);
DMXSerial.write(channel+1, 255 - (hue-510));
DMXSerial.write(channel+2, hue-510);
} // if
} // setChannelRGB() |