Skip to content

Instantly share code, notes, and snippets.

@smching
Created April 3, 2016 05:43
Show Gist options
  • Save smching/986ee3eedbb6dfbaff07ec7b26c5b7ec to your computer and use it in GitHub Desktop.
Save smching/986ee3eedbb6dfbaff07ec7b26c5b7ec to your computer and use it in GitHub Desktop.
Arduino communicate with Vixen Lighting Control Software
/*
16 Channels Lighting Controller
By smching (ediy.com.my)
Allow Arduino Mega to communicate with Vixen via generic serial plugin
*/
#define CHANNELS_COUNT 16
////////// PWM pin
#define Ch1 2 // PWM Pin 2
#define Ch2 3 // PWM Pin 3
#define Ch3 4 // PWM Pin 4
#define Ch4 5 // PWM Pin 5
#define Ch5 6 // PWM Pin 6
#define Ch6 7 // PWM Pin 7
#define Ch7 8 // PWM Pin 8
#define Ch8 9 // PWM Pin 9
#define Ch9 10 // PWM Pin 10
#define Ch10 11 // PWM Pin 11
#define Ch11 12 // PWM Pin 12
#define Ch12 13 // PWM Pin 13
/////////// digital pin
#define Ch13 18 // DIGITAL Pin 18
#define Ch14 19 // DIGITAL Pin 19
#define Ch15 20 // DIGITAL Pin 20
#define Ch16 21 // DIGITAL Pin 21
int Ch[CHANNELS_COUNT] = {Ch1, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7, Ch8, Ch9, Ch10, Ch11, Ch12, Ch13, Ch14, Ch15, Ch16};
int incomingByte[CHANNELS_COUNT]; // array to store the values from serial port
void setup()
{
Serial.begin(9600); // set up Serial at 9600 bps
for (byte i=0; i<CHANNELS_COUNT; i++) pinMode(Ch[i], OUTPUT); // declare channel pin as an output
}
void loop() {
if (Serial.available() >= CHANNELS_COUNT) {
for (int i=0; i<CHANNELS_COUNT; i++) {
incomingByte[i] = Serial.read(); // read each byte
if (i<12) { //arduino mega consists of 12 PWM
analogWrite(Ch[i], incomingByte[i]); // Write current values to LED pins
} else {
digitalWrite (Ch[i], incomingByte[i]); // Write the Digital Output to the LED pin.
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment