Hello All,
My Name is Rob and I have a question for those gifted in the writing of the script of c language. My question is, "Does anybody have or can write a simple code that uses the Conceptnetics or Marthertel libraries to control a single color led with a single DMX channel that either uses a 10 position dip switch or in code addressing?"
I am good at coming up with ideas but I fall flat when it comes to coding. I also have not found a thread that just is basic in DMX. I am looking for simple help from someone better at it. I get gist but not specifics.
Other basic code I would like is for a single servo also using DMX. Also just so there isn't a misunderstanding I am not looking for a "Master Code"(The code that tells lighting equipment what to do). I am looking for the "Slave Code" (It takes instructions on board from the master and then executes it as its own device similar to a moving head light) I also am not currently looking for a code that controls pixels (2811 and such).
Have you checked the examples that come with that.
The basic DMX_Slave
#include <Conceptinetics.h>
//
// CTC-DRA-13-1 ISOLATED DMX-RDM SHIELD JUMPER INSTRUCTIONS
//
// If you are using the above mentioned shield you should
// place the RXEN jumper towards G (Ground), This will turn
// the shield into read mode without using up an IO pin
//
// The !EN Jumper should be either placed in the G (GROUND)
// position to enable the shield circuitry
// OR
// if one of the pins is selected the selected pin should be
// set to OUTPUT mode and set to LOGIC LOW in order for the
// shield to work
//
//
// The slave device will use a block of 10 channels counting from
// its start address.
//
// If the start address is for example 56, then the channels kept
// by the dmx_slave object is channel 56-66
//
#define DMX_SLAVE_CHANNELS 10
//
// Pin number to change read or write mode on the shield
// Uncomment the following line if you choose to control
// read and write via a pin
//
// On the CTC-DRA-13-1 shield this will always be pin 2,
// if you are using other shields you should look it up
// yourself
//
///// #define RXEN_PIN 2
// Configure a DMX slave controller
DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS );
// If you are using an IO pin to control the shields RXEN
// the use the following line instead
///// DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS , RXEN_PIN );
const int ledPin = 13;
void setup() {
// Enable DMX slave interface and start recording
// DMX data
dmx_slave.enable ();
// Set start address to 1, this is also the default setting
// You can change this address at any time during the program
dmx_slave.setStartAddress (1);
// Set led pin as output pin
pinMode ( ledPin, OUTPUT );
}
void loop() {
//
// EXAMPLE DESCRIPTION
//
// If the first channel comes above 50% the led will switch on
// and below 50% the led will be turned off
// NOTE:
// getChannelValue is relative to the configured startaddress
if ( dmx_slave.getChannelValue (1) > 127 )
digitalWrite ( ledPin, HIGH );
else
digitalWrite ( ledPin, LOW );
}
With some modification that should work for you.
The Servo.h library has many conflicts with other things, but i think you should be able to do the same as you would with a LED. If not then you should seek a method that just sends a pulse manually
I think it is a bit early to refer to the jobs & paid consultancy.
If truly a novice at Arduino, here's a suggested path:
Get a single LED working on the Uno(use the onboard LED and the builtin sample)
Wire an LED to one of the PWM pins(use a series resistor!), and use the code from 1 to blink this new LED
Figure out how to dim, then brighten that LED
At this point, you have accomplished all but your item 2. Now, it gets interesting, as going RS485 on the native serial port, you cannot use Serial Monitor. Get this far, and we can guide you further.
I assume you refer to DMX_Serial by Matthias Hertel.
Here is an example that uses hardcoded address:
//
// Adapted from DmxSeriralRecv.ino by Bob Cousins 2025
//
#include <DMXSerial.h>
// Constants
const int LedPin = 11;
// Receives channel:
const int startChannel = 1;
void setup()
{
DMXSerial.init(DMXReceiver);
// set some default values
DMXSerial.write(1, 80);
// enable outputs
pinMode (LedPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
// Find time since last data received
unsigned long lastPacket = DMXSerial.noDataSince();
if (lastPacket < 5000)
{
// read recent DMX values and set pwm levels
uint8_t value = DMXSerial.read(startChannel);
analogWrite (LedPin, value);
}
else
{
// no DMX comms; go to fail safe
analogWrite (LedPin, 0);
}
}
// End.
Thank you Mr. Bob Cousins This code is perfect. If you are curious about a project I'm working on, it is a custom DMX device that will drive a 24V DC motor that drive a 3d printed gear pump of my own design for a mini fountain show.