'DMXtransmitterforweenieandtheMAX485chip'thisprogramiswrittenforthearduinomegaboard'andtheConceptineticsDMXshieldwhichisbasedonthe'MAX485signallingchip'seethesetupspecificsattheendofthecodebelow#chip mega2560, 16#include<maths.h>'************************COMMSETTINGS*******************************#define USART_BAUD_RATE 250000 ' Initializes USART port to 250000 baud#define USART_TX_BLOCKING ' wait for tx register to finish#define DMXout PORTE.1 ' Pin E.1, TX - out to MAX481 DMX driverdirDMXoutout'SetpindirectionssetDMXouton'DMXMARKcondition(DMXidle)#define DE PORTE.4 ' on the shield i'm using, this is fordirDEout'PinE.4,MAX485outputenablesetDEon#define LED PORTB.7 ' Pin B.7 - LEDdirLEDoutsetLEDoffUCSR0C=0b00001111'Async,8N2TXEN0=0'disableTX'************************FUNCTIONSETTINGS***************************#define MaxChan 10dimDMXCHAN(MaxChan)'CreateDMXarraydimxxasworddimyyasbyte'****************************EXECUTION*****************************'******************************SETUP*******************************ClrAll'ClearDMXarray'loadbufferwithtwovaluesSendChan(1,6)'enablefloodliteSendChan(4,255)'enabledumbcontrolofcolorsforxx=1to10'Blink"I'm alive"LEDpulseoutLED,60mswait60msnextxx'*****************************RUN**********************************do'thisroutinesendsasymetricsawtoothstreamofvaluesto'thegreenchannelofafloodlitetomakethegreenLEDs'slowlyfadeupanddownxx=xx+1direction=(xx/256)%2green=((xx%256)*direction)+(256-(xx%256))*(1-direction)SendChan(6,power((green/16),2))wait2msloop'************************SUBSbyMotoGeek************************subSendChan(Chan,Value)'updatesinglechannelDMXCHAN(Chan)=ValueTransDMXendsubsubSendAll(Value)'updateallchannelsforxx=1toMaxChanDMXCHAN(xx)=ValuenextxxTransDMXendsubsubClrAll'clearallchannelsforxx=1toMaxChanDMXCHAN(xx)=0nextxxTransDMXendsub'******************TRANSMITDMXChannels*************'thissubtransmits(MaxChan)oftheDMXarraysubTransDMXsetLEDon'ShowDMXactivityonLEDsetDMXoutoffwait100us'BREAKsetDMXoutonwait6us'MARKAFTERBREAK(MAB)TXEN0=1'enableTXHSerSend0'STARTCODE(always0)'setDMXouton'wait100ms'MarkTimeBetweenFrames(MTBF)'setDMXoutoffforyy=1toMaxChan'Channel1-(MaxChan)HSerSendDMXCHAN(yy)nextyyTXEN0=0'disableTXsetDMXouton'DMXMARKcondition(DMXidle)setLEDoffendsub'SPECS'writtenonSynWrite6.22.2290onWindows7-64'testedontheweeniemega2560r3'usingadmxshield,theConceptineticsCTC-DRA-10-R2'theshieldtakesserialdataonmegapinsD0(rx),D1(tx),D2(enable)'whichisserial0ontheatmega2560'theshieldhasanoptiontotakerxandtxfrompinsD3andD4'thisroutinesendsdmxdatatoacheapno-nameLEDfloodlite'asseenhere:https://www.youtube.com/watch?v=9wAr2UX-c5A'google:8CH12LEDcolorParLight'allitdoesiscontinuouslyfadethegreenupanddown'CREDITS'itookthecodewrittenbyMotoGeek'(https://sourceforge.net/p/gcbasic/discussion/projects&guides/thread/899e5a0b/?page=0)'andmodifieditforthe2560'thankstohim,toAnobiumandparticularlytoMike'(https://sourceforge.net/u/mmotte/profile/) for thier assistance
here is a video of my program at work:

https://www.youtube.com/watch?v=VOzxqHe4tm8
using MotoGeek's code as seen here: https://sourceforge.net/p/gcbasic/discussion/projects%26guides/thread/899e5a0b/
and modified for the weenie Mega2560 board.
dmxing a LED floodlite
Last edit: louie 2018-04-29