Skip to content

Instantly share code, notes, and snippets.

@Electronza
Created December 16, 2019 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Electronza/c9ef97ab95cd77c8a560ba5d09112eda to your computer and use it in GitHub Desktop.
Save Electronza/c9ef97ab95cd77c8a560ba5d09112eda to your computer and use it in GitHub Desktop.
Arduino DMX master #2
/*******************************************************************
____ __ ____ ___ ____ ____ __ __ _ ____ __
( __)( ) ( __)/ __)(_ _)( _ \ / \ ( ( \(__ ) / _\
) _) / (_/\ ) _)( (__ )( ) /( O )/ / / _/ / \
(____)\____/(____)\___) (__) (__\_) \__/ \_)__)(____)\_/\_/
Project name: Arduino DMX master
Project page: https://electronza.com/arduino-dmx-master-and-slave/
********************************************************************/
/*
Example code for using the Conceptinetics DMX library with RS485 click board from Mikroelectronika
CH1: Red
CH2: Blue
CH3: Green
Based on:
Conceptinetics DMX library,
Copyright (c) 2013 W.A. van der Meeren <danny@illogic.nl>. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
http://sourceforge.net/projects/dmxlibraryforar/files/
*/
// Be sure to download and install the library files first :)
#include <Conceptinetics.h>
// The master will control 3 Channels (3)
// depending on the amount of memory you have free you can choose
// to enlarge or shrink the amount of channels (minimum is 1)
#define DMX_MASTER_CHANNELS 3
// Pin number to change read or write mode on the shield
// Need to be 5 if slot#1 is used, or 6 if using slot #2
// The switch on Click Shieeld should be set on Prog when programming the code,
// and on UART
//
#define RXEN_PIN 6
// Configure a DMX master controller, the master controller
// will use the RXEN_PIN to control its write operation
// on the bus
DMX_Master dmx_master ( DMX_MASTER_CHANNELS, RXEN_PIN );
// the setup routine runs once when you press reset:
void setup() {
// Enable DMX master interface and start transmitting
dmx_master.enable ();
}
// the loop routine runs over and over again forever:
void loop()
{
// 3 Seconds of red light;
dmx_master.setChannelValue (1 , 255);
dmx_master.setChannelValue (2 , 0);
dmx_master.setChannelValue (3 , 0);
delay(3000);
// 3 Seconds of blue light;
dmx_master.setChannelValue (1 , 0);
dmx_master.setChannelValue (2 , 255);
dmx_master.setChannelValue (3 , 0);
delay(3000);
// 3 Seconds of green light;
dmx_master.setChannelValue (1 , 0);
dmx_master.setChannelValue (2 , 0);
dmx_master.setChannelValue (3 , 255);
delay(3000);
// 3 Seconds off;
dmx_master.setChannelValue (1 , 0);
dmx_master.setChannelValue (2 , 0);
dmx_master.setChannelValue (3 , 0);
delay(3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment