A DMX Controller

For our final assignment we needed to make a DMX controller to interact with at least one of the lights in the lounge. I chose those the Elation spotlight on the table and wanted to attempt to do it over wifi because it’s not something I’ve tried to tackle since last year.

I imagined two back to back sides that could rotate freely as controls, and used rotary encoders so that returning to an origin or keeping track of position was never an issue. The button would be in the middle to work as an on and off. This version of the controller is as far as I got for class. The microcontroller would successfully connect to the wifi but that’s where my successes paused for a bit. The encoders only read as always increasing, never decreasing, no mater how I turned them.

This problem turned to be me forgetting to ground them. Because I wasn’t planning to use the buttons, I’d forgotten about the other pins. But once I got them reading correctly? One of the encoders died…

So! Instead of of finding another and having one encoder for hue and one for brightness –  I’d have one encoder for everything! And I would now use pressing the button to change the mode between hue and brightness. Oren was kind enough to share his channel breakdown method and you’ll find that in here below. That definitely made targeting things much easier and was greatly appreciated

#include <Encoder.h>

#include <SPI.h>
#include <WiFi101.h>
#include <WiFiUdp.h>
#include <sACNSource.h>

#include “arduino_secrets.h”

WiFiUDP Udp; // instance of UDP library
sACNSource myController(Udp); // Your Ethernet-to-DMX device
//char receiverAddress[] = “”; // sACN receiver address
char receiverAddress[] = “”; //aaron’s lights

const int myUniverse = 1; // DMX universe
const char myDevice[] = “LDDMX”; // sender name
const char myUuid[] = “9e724033-431d-4e6c-a27e-afa07fd8ca24”; // sender UUID

const int ooPin = 2;
int ooState = false;

const int statePin = 5;
int hbState = 1;
int phbState = 1;
int hb = false;

Encoder brightKnob(6, 7);
long lastHPosition = 0;
long lastBPosition = 0;
int hValue = 50;
int bValue = 50;

// Elation Platinum Spot LED Pro II DMX Channels (thanks Oren)
const int baseDmxChannel = 201;
const int panChannel = baseDmxChannel;
const int panFineChannel = baseDmxChannel + 1;
const int tiltChannel = baseDmxChannel + 2;
const int tiltFineChannel = baseDmxChannel + 3;
const int colorWheelChannel = baseDmxChannel + 4;
const int continuousGobosChannel = baseDmxChannel + 5;
const int indexGobosChannel = baseDmxChannel + 6;
const int fixedGobosChannel = baseDmxChannel + 7;
const int prismGobosChannel = baseDmxChannel + 8;
const int focusChannel = baseDmxChannel + 9;
const int zoomChannel = baseDmxChannel + 10;
const int frostChannel = baseDmxChannel + 11;
const int shutterChannel = baseDmxChannel + 12;
const int dimmerChannel = baseDmxChannel + 13;
const int irisChannel = baseDmxChannel + 14;
const int movementSpeedChannel = baseDmxChannel + 15;
const int onOffChannel = baseDmxChannel + 16;

void setup() {

pinMode(ooPin, INPUT);
pinMode(statePin, INPUT);

// while you’re not connected to a WiFi AP,
while ( WiFi.status() != WL_CONNECTED) {
Serial.print(“Attempting to connect to Network named: “);
Serial.println(SECRET_SSID); // print the network name (SSID)
WiFi.begin(SECRET_SSID, SECRET_PASS); // try to connect

// initialize sACN source:
myController.begin(myDevice, myUuid, myUniverse);

// When you’re connected, print out the device’s network status:
IPAddress ip = WiFi.localIP();
Serial.print(“IP Address: “);

// set DMX channel values to 0:
for (int dmxChannel = 1; dmxChannel < 513; dmxChannel++) {
myController.setChannel(baseDmxChannel + dmxChannel, 0);
myController.setChannel(onOffChannel, 50 );
myController.setChannel(dimmerChannel, bValue);


void loop() {

// read ON OFF button
int buttonState = digitalRead(ooPin);
// Read hb

hbState = digitalRead(statePin);

/*Serial.print(“hb is “);

if(hbState != phbState && hbState == 0){
if(hb == false){
hb = true;
Serial.println(“hb is hue”);
else if(hb == true){
hb = false;
Serial.println(“hb is bright”);
phbState = hbState;

if(buttonState == LOW){
//keep that light off
Serial.println(“the light is off”);
ooState = false;
myController.setChannel(onOffChannel, 60);
else if(buttonState == HIGH){
//the light is on, do stuff
//Serial.println(“the light is on”);
ooState = true;
myController.setChannel(onOffChannel, 50);
myController.setChannel(dimmerChannel, bValue);

//if lightState == True –> do all this stuff that follows

if (ooState == true)
////////////////// read the HUE encoder /////////////////////////
/////////is broken…. HUE encodes no longer/////////////////////
///////////////////read the BRIGHT Encoder////////////////////////////
/////////////Bright encoder is now everything encoder/////////////////

int currentBPosition = brightKnob.read();

// see if it’s changed:
if (currentBPosition != lastBPosition && currentBPosition > lastBPosition) {

if(hb == false){
Serial.print(“bright value is “);
myController.setChannel(dimmerChannel, bValue);

if(hb == true){
Serial.print(“hue value is “);

if (currentBPosition != lastBPosition && currentBPosition < lastBPosition){
if(hb == false){
Serial.print(“bright value is “);
myController.setChannel(dimmerChannel, bValue);

if(hb == true){
Serial.print(“hue value is “);

lastBPosition = currentBPosition;
//else if lightState == false –> ignore all inputs and do nothing but save

Now I saw this work exactly one time. And then never again? Aaron took a look at it as well and we weren’t able to quite figure out why we couldn’t replicate my light control. So he set me up on a different wifi network to see if that was the problem.