Hello,
I am relative new, i bought a shield for DMX CTC-DRA-10-R2 to receive DMX data.
I would like to read 2 dmx channels and pending on their value set 6 different outputs.
(open/close/stop a curtain)
(turn increase / decrease / hold the light value in a venue)
I could upload my sketch and changed the jumper wire to 'EN' afterwards. I cannot use serial print due to the serial port is used by the shield.
the code is based on the 'slave' example downloaded with the library
#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 2
//
// 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 DOEKOPEN = 10;
const int DOEKDICHT = 11;
const int DOEKSTOP = 12;
const int LICHTAAN = 7;
const int LICHTUIT = 8;
const int LICHTSTOP = 9;
// the setup routine runs once when you press reset:
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 ( DOEKOPEN, OUTPUT );
pinMode ( DOEKDICHT, OUTPUT );
pinMode ( DOEKSTOP, OUTPUT );
pinMode ( LICHTAAN, OUTPUT );
pinMode ( LICHTUIT, OUTPUT );
pinMode ( LICHTSTOP, OUTPUT );
// digitalWrite ( VCCPIN , HIGH );
// digitalWrite ( GROUNDPIN, LOW );
//xin (9600);
}
// the loop routine runs over and over again forever:
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
// // DOEKDICHT
if ( dmx_slave.getChannelValue (1) < 50 )
digitalWrite ( DOEKDICHT, HIGH );
else
digitalWrite ( DOEKDICHT, LOW );
// // DOEKOPEN
if ( dmx_slave.getChannelValue (1) > 200 )
digitalWrite ( DOEKOPEN, HIGH );
else
digitalWrite ( DOEKOPEN, LOW );
// // DOEKSTOP
if ( (dmx_slave.getChannelValue (1) > 49) && (dmx_slave.getChannelValue (1) < 201) )
digitalWrite ( DOEKSTOP, HIGH );
else
digitalWrite ( DOEKSTOP, LOW );
// // LICHTUIT
if ( dmx_slave.getChannelValue (2) < 50 )
digitalWrite ( LICHTUIT, HIGH );
else
digitalWrite ( LICHTUIT, LOW );
// // LICHTAAN
if ( dmx_slave.getChannelValue (2) > 200 )
digitalWrite ( LICHTAAN, HIGH );
else
digitalWrite ( LICHTAAN, LOW );
// // LICHTSTOP
if ( (dmx_slave.getChannelValue (2) > 49) && (dmx_slave.getChannelValue (2) < 201) )
digitalWrite ( LICHTSTOP, HIGH );
else
digitalWrite ( LICHTSTOP, LOW );
}
Jumper settings after uploading sketch are:
EN <= NOT EN
SLAVE <= MASTER
TX-io <= TX uart
RX-io <= RX uart
So all jumpers are left side.
thanks in advance for feedback/help
best regards!