Thursday, February 17, 2011

6 channel serial LED Dimmer w/ Arduino

While continuing research for senior project we came across the LanBox DMX controller. It essentially takes a hex string and converts it to DMX. Since the LanBox is expensive and we only have one, I wanted to make something that could function similarly for prototyping applications.

What I came up with was using all 6 PWM pins on the Arduino and assigning them intensities through a serial string beginning with "A"

Since allowable intensities varied between 0 and 255 I had the code break down the serial string into chunks of 3 characters. I dont know a whole ton about hex, but it would have been ideal.

So if you send the string "A255000255000122200"
channel intensities would be
  1. 255
  2. 000
  3. 255
  4. 000
  5. 122
  6. 200

The idea is that a whole string of all the instrument (LED) values would be sent in some sort of loop to control dimming operations so that minimal to no code would have to reside on the dmx device improving reliability of the system.

In the meantime, this is the code that I have come up with ideally I would like to be able to send information only on certain channels with some sort of identifier.

The exact code that is currently in use can be found after the break

 this is a chunk of stuff to fade 3 leds from serial read

//Callout LED pins
int ledA = 3;
int ledD = 5;
int ledC = 6;
int ledE = 9;
int ledF = 10;
int ledG = 11;

double A_lvl =64;
double D_lvl =64;
double C_lvl =64;
double E_lvl =64;
double F_lvl =64;
double G_lvl =64;
char kind_of_data;

void setup() {
  analogWrite(ledA, A_lvl);         
  analogWrite(ledD, D_lvl);   
  analogWrite(ledC, C_lvl);
  analogWrite(ledE, E_lvl);         
  analogWrite(ledF, F_lvl);   
  analogWrite(ledG, G_lvl);

void loop()  { 
  while(Serial.available() > 0)
    kind_of_data =;
    if (kind_of_data == 'A' ) {

      double A100 = '0';
      double A10 = '0';
      double A1 = '0';

      double D100 = '0';
      double D10 = '0';
      double D1 = '0';

      double C100 = '0';
      double C10 = '0';
      double C1 = '0';

      double E100 = '0';
      double E10 = '0';
      double E1 = '0';

      double F100 = '0';
      double F10 = '0';
      double F1 = '0';

      double G100 = '0';
      double G10 = '0';
      double G1 = '0';

      analogWrite(ledA, int(A_lvl));         
      analogWrite(ledD, int(D_lvl));   
      analogWrite(ledC, int(C_lvl));
      analogWrite(ledE, int(E_lvl));         
      analogWrite(ledF, int(F_lvl));   
      analogWrite(ledG, int(G_lvl));

      Serial.print("A: ");
      Serial.print("D: ");
      Serial.print("C: ");
      Serial.print("E: ");
      Serial.print("F: ");
      Serial.print("G: ");

1 comment:

  1. Hi, My name is Paul and I am the admin of a site called HackHut. You obviously have a lot of skill, and I just wanted to let you know about HackHut because it seems like a perfect fit for you. We are a hosting service somewhat like wordpress, blogspot, or Instructables accept run by and geared toward the hacker/DIYer. We offer, or are working on features that people like you want and can use. I hope you check us out and feel free to contact me there if you have any requests for features or questions about the site.