Created
December 16, 2019 09:11
-
-
Save Electronza/4f8aa9388c7d366292f21006f87d349c to your computer and use it in GitHub Desktop.
Arduino DMX master using RS485 click board
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************* | |
____ __ ____ ___ ____ ____ __ __ _ ____ __ | |
( __)( ) ( __)/ __)(_ _)( _ \ / \ ( ( \(__ ) / _\ | |
) _) / (_/\ ) _)( (__ )( ) /( O )/ / / _/ / \ | |
(____)\____/(____)\___) (__) (__\_) \__/ \_)__)(____)\_/\_/ | |
Project name: Arduino DMX master using RS485 click board | |
Project page: https://electronza.com/arduino-dmx-master-using-rs485-click-board/ | |
Dependencies: https://sourceforge.net/projects/dmxlibraryforar/files/ | |
********************************************************************/ | |
/* | |
Example code for using the Conceptinetics DMX library with RS485 click board from Mikroelectronika | |
DMX fixture is a T-36 PAR from Eurolite | |
CH1: Red | |
CH2: Blue | |
CH3: Green | |
CH4: Dimming (global) | |
CH5: Flash (0:10 - noflash, 11:255 - flash 0:100%) | |
Ver.1.0, 7 July 2015 | |
http://microcontroller-projects.com | |
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 :) | |
#include <Conceptinetics.h> | |
// The master will control 5 Channels (1-5) | |
// | |
// depending on the ammount of memory you have free you can choose | |
// to enlarge or schrink the ammount of channels (minimum is 1) | |
// | |
#define DMX_MASTER_CHANNELS 5 | |
// | |
// 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 URAT | |
// | |
#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 (); | |
// I have to set first the dimmer channel to 100% | |
dmx_master.setChannelValue (4 , 255); | |
// 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); | |
} | |
// the loop routine runs over and over again forever: | |
void loop() | |
{ | |
static int dimmer_val; | |
// Keep fading channel 1 in from 0 to 100% | |
for (int dimmer_val = 1; dimmer_val >= 255; dimmer_val++) { | |
dmx_master.setChannelValue ( 1, dimmer_val); | |
delay(100); // from 0 to 100% in about 2.5 seconds | |
} | |
// Now dimming channel 1 in from 100% to 0 | |
for (int dimmer_val = 254; dimmer_val >= 1; dimmer_val--) { | |
dmx_master.setChannelValue ( 1, dimmer_val); | |
delay(100); // from 0 to 100% in about 2.5 seconds | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment