Code does not execute properly unless Arduino is connected to PC

Hello all,

Bit of a head scratcher here...

I have a MKR 1500 NB that when connected to my USB port runs perfectly but when not it enters a reset loop.

I researched the forum and found many posts about this being electrical issues, grounding etc. However I am pretty sure this is not the case. To confirm I cut open my USB cable and snipped the data lines and left the USB connected to the PC, when I did this the issue returned... When I reconnected the data lines the issue resolved.

I am thinking that this has to do with the 'serial.begin' command and and the subsequent delay that is in the Arudino IoT cloud produced code. It says that the delay is there to stop blocking but when the delay is there, the WDT times out before the board is able to connect to the cloud.

Any advice would be greatly appreciated.

Here is my code, I have cut off the void loop as it is very long and mostly DMX values.

I have tried many variations of commenting in/out the serial.begin and delay() but to no avail.

Ty

M

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
  https://create.arduino.cc/cloud/things/// redacted

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudColor aColour;
  CloudColor bColour;
  CloudColor cColour;
  int current;
  int fxSpeed;
  CloudSchedule hbSched;
  CloudSchedule onTime;
  bool effect;
  bool heartbeat;
  bool power;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

// ArduinoRS485 - Version: Latest 
#include <ArduinoRS485.h>

// ArduinoDMX - Version: Latest 
#include <ArduinoDMX.h>

#include "thingProperties.h".

const int hbPin = 8;
const int statusB = 3;

const int universeSize = 180;

unsigned long lastToggleTime = 0;
unsigned long lastLuxTime = 0;
bool statusBState = false;


void setup() {
  
  //Serial.begin(9600);
 //delay(1500);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  

  pinMode(hbPin, OUTPUT);
  pinMode(statusB, OUTPUT);

  DMX.begin(universeSize);
 
  }

You ever waiting on serial data? Somewhere in loop()?
Boost your baud rate to 115200.
Try polling instead of a hard delay()

To be honest, the length of your code won't scare us off, but the context is oftentimes important; also, the number of times the problem has actually turned out to be in the code not shared is quite high, so please, post your entire code.

what isn't is doing that makes you think it's not working?
will be hard to evaluate without seeing more of the code.
have you tried something simpler

i built an NCE compatible DCC controller using an Arduino UNO that uses an rs-485 interface to the DCC command station. it runs independently using external power provide from the command station

it was challenging to debug it since the serial interface was used by the application and unavailable for debugging. used an Arduino Mega which has 4 serial interfaces to do most of the development as well as using it to monitor messages on the rs-485 bus to verify the UNO application on the same rs-485 bus. Leds can also be used for debugging

2 Likes

Hi @madmark2150,

Thank you for taking some time to look at this for me.

I had put a flag in the code to serial.print and hadn't removed it, I was sure this was going to be the problem but after removing it unfortunately the issue remains.

I tried 115200 with and without the delay, but this has not solved the issue.

I have tried the below to no avail, is this what you mean by polling?

Serial.begin(9600);
while(!Serial.available()) {
}

Best,

M

Hi @camsysca,

Thank you very much for this and you are right, just didn't want to annoy anyone.

Here you go...

/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
  https://create.arduino.cc/cloud/things/redacted

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudColor aColour;
  CloudColor bColour;
  CloudColor cColour;
  int current;
  int fxSpeed;
  CloudSchedule hbSched;
  CloudSchedule onTime;
  bool effect;
  bool heartbeat;
  bool power;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

// ArduinoRS485 - Version: Latest
#include <ArduinoRS485.h>

// ArduinoDMX - Version: Latest
#include <ArduinoDMX.h>

#include "thingProperties.h".

const int hbPin = 8;
const int statusB = 3;

const int universeSize = 180;

unsigned long lastToggleTime = 0;
unsigned long lastLuxTime = 0;
bool statusBState = false;


void setup() {

Serial.begin(9600);
while(!Serial.available()) {
  // wait for data to be available on the serial port
}


  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);



  pinMode(hbPin, OUTPUT);
  pinMode(statusB, OUTPUT);

  DMX.begin(universeSize);

}



void loop() {

  DMX.beginTransmission();

  ArduinoCloud.update();


  byte aRValue, aGValue, aBValue;
  byte bRValue, bGValue, bBValue;
  byte cRValue, cGValue, cBValue;

  Color aCurrentColour(aColour.getValue().hue, aColour.getValue().sat, aColour.getValue().bri);
  aCurrentColour.getRGB(aRValue, aGValue, aBValue);

  Color bCurrentColour(bColour.getValue().hue, bColour.getValue().sat, bColour.getValue().bri);
  bCurrentColour.getRGB(bRValue, bGValue, bBValue);

  Color cCurrentColour(cColour.getValue().hue, cColour.getValue().sat, cColour.getValue().bri);
  cCurrentColour.getRGB(cRValue, cGValue, cBValue);

  if (onTime.isActive()) {

    power = true;

    if (effect == 1) {

      unsigned long currentTime = millis(); // get the current time
      static unsigned long previousTime = currentTime;
      static int step = 0;

      if (currentTime - previousTime >= fxSpeed) {
        previousTime = currentTime;

        switch (step) {
          case 0:


            DMX.write(1, aRValue);
            DMX.write(2, aGValue);
            DMX.write(3, aBValue);
            DMX.write(4, bRValue);
            DMX.write(5, bGValue);
            DMX.write(6, bBValue);
            DMX.write(7, cRValue);
            DMX.write(8, cGValue);
            DMX.write(9, cBValue);
            DMX.write(10, aRValue);
            DMX.write(11, aGValue);
            DMX.write(12, aBValue);
            DMX.write(13, bRValue);
            DMX.write(14, bGValue);
            DMX.write(15, bBValue);
            DMX.write(16, cRValue);
            DMX.write(17, cGValue);
            DMX.write(18, cBValue);
            DMX.write(19, aRValue);
            DMX.write(20, aGValue);
            DMX.write(21, aBValue);
            DMX.write(22, bRValue);
            DMX.write(23, bGValue);
            DMX.write(24, bBValue);
            DMX.write(25, cRValue);
            DMX.write(26, cGValue);
            DMX.write(27, cBValue);
            DMX.write(28, aRValue);
            DMX.write(29, aGValue);
            DMX.write(30, aBValue);
            DMX.write(31, bRValue);
            DMX.write(32, bGValue);
            DMX.write(33, bBValue);
            DMX.write(34, cRValue);
            DMX.write(35, cGValue);
            DMX.write(36, cBValue);
            DMX.write(37, aRValue);
            DMX.write(38, aGValue);
            DMX.write(39, aBValue);
            DMX.write(40, bRValue);
            DMX.write(41, bGValue);
            DMX.write(42, bBValue);
            DMX.write(43, cRValue);
            DMX.write(44, cGValue);
            DMX.write(45, cBValue);
            DMX.write(46, aRValue);
            DMX.write(47, aGValue);
            DMX.write(48, aBValue);
            DMX.write(49, bRValue);
            DMX.write(50, bGValue);
            DMX.write(51, bBValue);
            DMX.write(52, cRValue);
            DMX.write(53, cGValue);
            DMX.write(54, cBValue);
            DMX.write(55, aRValue);
            DMX.write(56, aGValue);
            DMX.write(57, aBValue);
            DMX.write(58, bRValue);
            DMX.write(59, bGValue);
            DMX.write(60, bBValue);
            DMX.write(61, cRValue);
            DMX.write(62, cGValue);
            DMX.write(63, cBValue);
            DMX.write(64, aRValue);
            DMX.write(65, aGValue);
            DMX.write(66, aBValue);
            DMX.write(67, bRValue);
            DMX.write(68, bGValue);
            DMX.write(69, bBValue);
            DMX.write(70, cRValue);
            DMX.write(71, cGValue);
            DMX.write(72, cBValue);
            DMX.write(73, aRValue);
            DMX.write(74, aGValue);
            DMX.write(75, aBValue);
            DMX.write(76, bRValue);
            DMX.write(77, bGValue);
            DMX.write(78, bBValue);
            DMX.write(79, cRValue);
            DMX.write(80, cGValue);
            DMX.write(81, cBValue);
            DMX.write(82, aRValue);
            DMX.write(83, aGValue);
            DMX.write(84, aBValue);
            DMX.write(85, bRValue);
            DMX.write(86, bGValue);
            DMX.write(87, bBValue);
            DMX.write(88, cRValue);
            DMX.write(89, cGValue);
            DMX.write(90, cBValue);
            DMX.write(91, aRValue);
            DMX.write(92, aGValue);
            DMX.write(93, aBValue);
            DMX.write(94, bRValue);
            DMX.write(95, bGValue);
            DMX.write(96, bBValue);
            DMX.write(97, cRValue);
            DMX.write(98, cGValue);
            DMX.write(99, cBValue);
            DMX.write(100, aRValue);
            DMX.write(101, aGValue);
            DMX.write(102, aBValue);
            DMX.write(103, bRValue);
            DMX.write(104, bGValue);
            DMX.write(105, bBValue);
            DMX.write(106, cRValue);
            DMX.write(107, cGValue);
            DMX.write(108, cBValue);
            DMX.write(109, aRValue);
            DMX.write(110, aGValue);
            DMX.write(111, aBValue);
            DMX.write(112, bRValue);
            DMX.write(113, bGValue);
            DMX.write(114, bBValue);
            DMX.write(115, cRValue);
            DMX.write(116, cGValue);
            DMX.write(117, cBValue);
            DMX.write(118, aRValue);
            DMX.write(119, aGValue);
            DMX.write(120, aBValue);
            DMX.write(121, bRValue);
            DMX.write(122, bGValue);
            DMX.write(123, bBValue);
            DMX.write(124, cRValue);
            DMX.write(125, cGValue);
            DMX.write(126, cBValue);
            DMX.write(127, aRValue);
            DMX.write(128, aGValue);
            DMX.write(129, aBValue);
            DMX.write(130, bRValue);
            DMX.write(131, bGValue);
            DMX.write(132, bBValue);
            DMX.write(133, cRValue);
            DMX.write(134, cGValue);
            DMX.write(135, cBValue);
            DMX.write(136, aRValue);
            DMX.write(137, aGValue);
            DMX.write(138, aBValue);
            DMX.write(139, bRValue);
            DMX.write(140, bGValue);
            DMX.write(141, bBValue);
            DMX.write(142, cRValue);
            DMX.write(143, cGValue);
            DMX.write(144, cBValue);
            DMX.write(145, aRValue);
            DMX.write(146, aGValue);
            DMX.write(147, aBValue);
            DMX.write(148, bRValue);
            DMX.write(149, bGValue);
            DMX.write(150, bBValue);
            DMX.write(151, cRValue);
            DMX.write(152, cGValue);
            DMX.write(153, cBValue);
            DMX.write(154, aRValue);
            DMX.write(155, aGValue);
            DMX.write(156, aBValue);
            DMX.write(157, bRValue);
            DMX.write(158, bGValue);
            DMX.write(159, bBValue);
            DMX.write(160, cRValue);
            DMX.write(161, cGValue);
            DMX.write(162, cBValue);
            DMX.write(163, aRValue);
            DMX.write(164, aGValue);
            DMX.write(165, aBValue);
            DMX.write(166, bRValue);
            DMX.write(167, bGValue);
            DMX.write(168, bBValue);
            DMX.write(169, cRValue);
            DMX.write(170, cGValue);
            DMX.write(171, cBValue);
            DMX.write(172, aRValue);
            DMX.write(173, aGValue);
            DMX.write(174, aBValue);
            DMX.write(175, bRValue);
            DMX.write(176, bGValue);
            DMX.write(177, bBValue);
            DMX.write(178, cRValue);
            DMX.write(179, cGValue);
            DMX.write(180, cBValue);




            break;

          case 1:




            DMX.write(1, cRValue);
            DMX.write(2, cGValue);
            DMX.write(3, cBValue);
            DMX.write(4, aRValue);
            DMX.write(5, aGValue);
            DMX.write(6, aBValue);
            DMX.write(7, bRValue);
            DMX.write(8, bGValue);
            DMX.write(9, bBValue);
            DMX.write(10, cRValue);
            DMX.write(11, cGValue);
            DMX.write(12, cBValue);
            DMX.write(13, aRValue);
            DMX.write(14, aGValue);
            DMX.write(15, aBValue);
            DMX.write(16, bRValue);
            DMX.write(17, bGValue);
            DMX.write(18, bBValue);
            DMX.write(19, cRValue);
            DMX.write(20, cGValue);
            DMX.write(21, cBValue);
            DMX.write(22, aRValue);
            DMX.write(23, aGValue);
            DMX.write(24, aBValue);
            DMX.write(25, bRValue);
            DMX.write(26, bGValue);
            DMX.write(27, bBValue);
            DMX.write(28, cRValue);
            DMX.write(29, cGValue);
            DMX.write(30, cBValue);
            DMX.write(31, aRValue);
            DMX.write(32, aGValue);
            DMX.write(33, aBValue);
            DMX.write(34, bRValue);
            DMX.write(35, bGValue);
            DMX.write(36, bBValue);
            DMX.write(37, cRValue);
            DMX.write(38, cGValue);
            DMX.write(39, cBValue);
            DMX.write(40, aRValue);
            DMX.write(41, aGValue);
            DMX.write(42, aBValue);
            DMX.write(43, bRValue);
            DMX.write(44, bGValue);
            DMX.write(45, bBValue);
            DMX.write(46, cRValue);
            DMX.write(47, cGValue);
            DMX.write(48, cBValue);
            DMX.write(49, aRValue);
            DMX.write(50, aGValue);
            DMX.write(51, aBValue);
            DMX.write(52, bRValue);
            DMX.write(53, bGValue);
            DMX.write(54, bBValue);
            DMX.write(55, cRValue);
            DMX.write(56, cGValue);
            DMX.write(57, cBValue);
            DMX.write(58, aRValue);
            DMX.write(59, aGValue);
            DMX.write(60, aBValue);
            DMX.write(61, bRValue);
            DMX.write(62, bGValue);
            DMX.write(63, bBValue);
            DMX.write(64, cRValue);
            DMX.write(65, cGValue);
            DMX.write(66, cBValue);
            DMX.write(67, aRValue);
            DMX.write(68, aGValue);
            DMX.write(69, aBValue);
            DMX.write(70, bRValue);
            DMX.write(71, bGValue);
            DMX.write(72, bBValue);
            DMX.write(73, cRValue);
            DMX.write(74, cGValue);
            DMX.write(75, cBValue);
            DMX.write(76, aRValue);
            DMX.write(77, aGValue);
            DMX.write(78, aBValue);
            DMX.write(79, bRValue);
            DMX.write(80, bGValue);
            DMX.write(81, bBValue);
            DMX.write(82, cRValue);
            DMX.write(83, cGValue);
            DMX.write(84, cBValue);
            DMX.write(85, aRValue);
            DMX.write(86, aGValue);
            DMX.write(87, aBValue);
            DMX.write(88, bRValue);
            DMX.write(89, bGValue);
            DMX.write(90, bBValue);
            DMX.write(91, cRValue);
            DMX.write(92, cGValue);
            DMX.write(93, cBValue);
            DMX.write(94, aRValue);
            DMX.write(95, aGValue);
            DMX.write(96, aBValue);
            DMX.write(97, bRValue);
            DMX.write(98, bGValue);
            DMX.write(99, bBValue);
            DMX.write(100, cRValue);
            DMX.write(101, cGValue);
            DMX.write(102, cBValue);
            DMX.write(103, aRValue);
            DMX.write(104, aGValue);
            DMX.write(105, aBValue);
            DMX.write(106, bRValue);
            DMX.write(107, bGValue);
            DMX.write(108, bBValue);
            DMX.write(109, cRValue);
            DMX.write(110, cGValue);
            DMX.write(111, cBValue);
            DMX.write(112, aRValue);
            DMX.write(113, aGValue);
            DMX.write(114, aBValue);
            DMX.write(115, bRValue);
            DMX.write(116, bGValue);
            DMX.write(117, bBValue);
            DMX.write(118, cRValue);
            DMX.write(119, cGValue);
            DMX.write(120, cBValue);
            DMX.write(121, aRValue);
            DMX.write(122, aGValue);
            DMX.write(123, aBValue);
            DMX.write(124, bRValue);
            DMX.write(125, bGValue);
            DMX.write(126, bBValue);
            DMX.write(127, cRValue);
            DMX.write(128, cGValue);
            DMX.write(129, cBValue);
            DMX.write(130, aRValue);
            DMX.write(131, aGValue);
            DMX.write(132, aBValue);
            DMX.write(133, bRValue);
            DMX.write(134, bGValue);
            DMX.write(135, bBValue);
            DMX.write(136, cRValue);
            DMX.write(137, cGValue);
            DMX.write(138, cBValue);
            DMX.write(139, aRValue);
            DMX.write(140, aGValue);
            DMX.write(141, aBValue);
            DMX.write(142, bRValue);
            DMX.write(143, bGValue);
            DMX.write(144, bBValue);
            DMX.write(145, cRValue);
            DMX.write(146, cGValue);
            DMX.write(147, cBValue);
            DMX.write(148, aRValue);
            DMX.write(149, aGValue);
            DMX.write(150, aBValue);
            DMX.write(151, bRValue);
            DMX.write(152, bGValue);
            DMX.write(153, bBValue);
            DMX.write(154, cRValue);
            DMX.write(155, cGValue);
            DMX.write(156, cBValue);
            DMX.write(157, aRValue);
            DMX.write(158, aGValue);
            DMX.write(159, aBValue);
            DMX.write(160, bRValue);
            DMX.write(161, bGValue);
            DMX.write(162, bBValue);
            DMX.write(163, cRValue);
            DMX.write(164, cGValue);
            DMX.write(165, cBValue);
            DMX.write(166, aRValue);
            DMX.write(167, aGValue);
            DMX.write(168, aBValue);
            DMX.write(169, bRValue);
            DMX.write(170, bGValue);
            DMX.write(171, bBValue);
            DMX.write(172, cRValue);
            DMX.write(173, cGValue);
            DMX.write(174, cBValue);
            DMX.write(175, aRValue);
            DMX.write(176, aGValue);
            DMX.write(177, aBValue);
            DMX.write(178, bRValue);
            DMX.write(179, bGValue);
            DMX.write(180, bBValue);



            break;

          case 2:



            DMX.write(1, bRValue);
            DMX.write(2, bGValue);
            DMX.write(3, bBValue);
            DMX.write(4, cRValue);
            DMX.write(5, cGValue);
            DMX.write(6, cBValue);
            DMX.write(7, aRValue);
            DMX.write(8, aGValue);
            DMX.write(9, aBValue);
            DMX.write(10, bRValue);
            DMX.write(11, bGValue);
            DMX.write(12, bBValue);
            DMX.write(13, cRValue);
            DMX.write(14, cGValue);
            DMX.write(15, cBValue);
            DMX.write(16, aRValue);
            DMX.write(17, aGValue);
            DMX.write(18, aBValue);
            DMX.write(19, bRValue);
            DMX.write(20, bGValue);
            DMX.write(21, bBValue);
            DMX.write(22, cRValue);
            DMX.write(23, cGValue);
            DMX.write(24, cBValue);
            DMX.write(25, aRValue);
            DMX.write(26, aGValue);
            DMX.write(27, aBValue);
            DMX.write(28, bRValue);
            DMX.write(29, bGValue);
            DMX.write(30, bBValue);
            DMX.write(31, cRValue);
            DMX.write(32, cGValue);
            DMX.write(33, cBValue);
            DMX.write(34, aRValue);
            DMX.write(35, aGValue);
            DMX.write(36, aBValue);
            DMX.write(37, bRValue);
            DMX.write(38, bGValue);
            DMX.write(39, bBValue);
            DMX.write(40, cRValue);
            DMX.write(41, cGValue);
            DMX.write(42, cBValue);
            DMX.write(43, aRValue);
            DMX.write(44, aGValue);
            DMX.write(45, aBValue);
            DMX.write(46, bRValue);
            DMX.write(47, bGValue);
            DMX.write(48, bBValue);
            DMX.write(49, cRValue);
            DMX.write(50, cGValue);
            DMX.write(51, cBValue);
            DMX.write(52, aRValue);
            DMX.write(53, aGValue);
            DMX.write(54, aBValue);
            DMX.write(55, bRValue);
            DMX.write(56, bGValue);
            DMX.write(57, bBValue);
            DMX.write(58, cRValue);
            DMX.write(59, cGValue);
            DMX.write(60, cBValue);
            DMX.write(61, aRValue);
            DMX.write(62, aGValue);
            DMX.write(63, aBValue);
            DMX.write(64, bRValue);
            DMX.write(65, bGValue);
            DMX.write(66, bBValue);
            DMX.write(67, cRValue);
            DMX.write(68, cGValue);
            DMX.write(69, cBValue);
            DMX.write(70, aRValue);
            DMX.write(71, aGValue);
            DMX.write(72, aBValue);
            DMX.write(73, bRValue);
            DMX.write(74, bGValue);
            DMX.write(75, bBValue);
            DMX.write(76, cRValue);
            DMX.write(77, cGValue);
            DMX.write(78, cBValue);
            DMX.write(79, aRValue);
            DMX.write(80, aGValue);
            DMX.write(81, aBValue);
            DMX.write(82, bRValue);
            DMX.write(83, bGValue);
            DMX.write(84, bBValue);
            DMX.write(85, cRValue);
            DMX.write(86, cGValue);
            DMX.write(87, cBValue);
            DMX.write(88, aRValue);
            DMX.write(89, aGValue);
            DMX.write(90, aBValue);
            DMX.write(91, bRValue);
            DMX.write(92, bGValue);
            DMX.write(93, bBValue);
            DMX.write(94, cRValue);
            DMX.write(95, cGValue);
            DMX.write(96, cBValue);
            DMX.write(97, aRValue);
            DMX.write(98, aGValue);
            DMX.write(99, aBValue);
            DMX.write(100, bRValue);
            DMX.write(101, bGValue);
            DMX.write(102, bBValue);
            DMX.write(103, cRValue);
            DMX.write(104, cGValue);
            DMX.write(105, cBValue);
            DMX.write(106, aRValue);
            DMX.write(107, aGValue);
            DMX.write(108, aBValue);
            DMX.write(109, bRValue);
            DMX.write(110, bGValue);
            DMX.write(111, bBValue);
            DMX.write(112, cRValue);
            DMX.write(113, cGValue);
            DMX.write(114, cBValue);
            DMX.write(115, aRValue);
            DMX.write(116, aGValue);
            DMX.write(117, aBValue);
            DMX.write(118, bRValue);
            DMX.write(119, bGValue);
            DMX.write(120, bBValue);
            DMX.write(121, cRValue);
            DMX.write(122, cGValue);
            DMX.write(123, cBValue);
            DMX.write(124, aRValue);
            DMX.write(125, aGValue);
            DMX.write(126, aBValue);
            DMX.write(127, bRValue);
            DMX.write(128, bGValue);
            DMX.write(129, bBValue);
            DMX.write(130, cRValue);
            DMX.write(131, cGValue);
            DMX.write(132, cBValue);
            DMX.write(133, aRValue);
            DMX.write(134, aGValue);
            DMX.write(135, aBValue);
            DMX.write(136, bRValue);
            DMX.write(137, bGValue);
            DMX.write(138, bBValue);
            DMX.write(139, cRValue);
            DMX.write(140, cGValue);
            DMX.write(141, cBValue);
            DMX.write(142, aRValue);
            DMX.write(143, aGValue);
            DMX.write(144, aBValue);
            DMX.write(145, bRValue);
            DMX.write(146, bGValue);
            DMX.write(147, bBValue);
            DMX.write(148, cRValue);
            DMX.write(149, cGValue);
            DMX.write(150, cBValue);
            DMX.write(151, aRValue);
            DMX.write(152, aGValue);
            DMX.write(153, aBValue);
            DMX.write(154, bRValue);
            DMX.write(155, bGValue);
            DMX.write(156, bBValue);
            DMX.write(157, cRValue);
            DMX.write(158, cGValue);
            DMX.write(159, cBValue);
            DMX.write(160, aRValue);
            DMX.write(161, aGValue);
            DMX.write(162, aBValue);
            DMX.write(163, bRValue);
            DMX.write(164, bGValue);
            DMX.write(165, bBValue);
            DMX.write(166, cRValue);
            DMX.write(167, cGValue);
            DMX.write(168, cBValue);
            DMX.write(169, aRValue);
            DMX.write(170, aGValue);
            DMX.write(171, aBValue);
            DMX.write(172, bRValue);
            DMX.write(173, bGValue);
            DMX.write(174, bBValue);
            DMX.write(175, cRValue);
            DMX.write(176, cGValue);
            DMX.write(177, cBValue);
            DMX.write(178, aRValue);
            DMX.write(179, aGValue);
            DMX.write(180, aBValue);



            break;
        }

        step++;
        if (step > 2) {
          step = 0;
        }
      }

    } else {


      DMX.write(1, aRValue);
      DMX.write(2, aGValue);
      DMX.write(3, aBValue);
      DMX.write(4, bRValue);
      DMX.write(5, bGValue);
      DMX.write(6, bBValue);
      DMX.write(7, cRValue);
      DMX.write(8, cGValue);
      DMX.write(9, cBValue);
      DMX.write(10, aRValue);
      DMX.write(11, aGValue);
      DMX.write(12, aBValue);
      DMX.write(13, bRValue);
      DMX.write(14, bGValue);
      DMX.write(15, bBValue);
      DMX.write(16, cRValue);
      DMX.write(17, cGValue);
      DMX.write(18, cBValue);
      DMX.write(19, aRValue);
      DMX.write(20, aGValue);
      DMX.write(21, aBValue);
      DMX.write(22, bRValue);
      DMX.write(23, bGValue);
      DMX.write(24, bBValue);
      DMX.write(25, cRValue);
      DMX.write(26, cGValue);
      DMX.write(27, cBValue);
      DMX.write(28, aRValue);
      DMX.write(29, aGValue);
      DMX.write(30, aBValue);
      DMX.write(31, bRValue);
      DMX.write(32, bGValue);
      DMX.write(33, bBValue);
      DMX.write(34, cRValue);
      DMX.write(35, cGValue);
      DMX.write(36, cBValue);
      DMX.write(37, aRValue);
      DMX.write(38, aGValue);
      DMX.write(39, aBValue);
      DMX.write(40, bRValue);
      DMX.write(41, bGValue);
      DMX.write(42, bBValue);
      DMX.write(43, cRValue);
      DMX.write(44, cGValue);
      DMX.write(45, cBValue);
      DMX.write(46, aRValue);
      DMX.write(47, aGValue);
      DMX.write(48, aBValue);
      DMX.write(49, bRValue);
      DMX.write(50, bGValue);
      DMX.write(51, bBValue);
      DMX.write(52, cRValue);
      DMX.write(53, cGValue);
      DMX.write(54, cBValue);
      DMX.write(55, aRValue);
      DMX.write(56, aGValue);
      DMX.write(57, aBValue);
      DMX.write(58, bRValue);
      DMX.write(59, bGValue);
      DMX.write(60, bBValue);
      DMX.write(61, cRValue);
      DMX.write(62, cGValue);
      DMX.write(63, cBValue);
      DMX.write(64, aRValue);
      DMX.write(65, aGValue);
      DMX.write(66, aBValue);
      DMX.write(67, bRValue);
      DMX.write(68, bGValue);
      DMX.write(69, bBValue);
      DMX.write(70, cRValue);
      DMX.write(71, cGValue);
      DMX.write(72, cBValue);
      DMX.write(73, aRValue);
      DMX.write(74, aGValue);
      DMX.write(75, aBValue);
      DMX.write(76, bRValue);
      DMX.write(77, bGValue);
      DMX.write(78, bBValue);
      DMX.write(79, cRValue);
      DMX.write(80, cGValue);
      DMX.write(81, cBValue);
      DMX.write(82, aRValue);
      DMX.write(83, aGValue);
      DMX.write(84, aBValue);
      DMX.write(85, bRValue);
      DMX.write(86, bGValue);
      DMX.write(87, bBValue);
      DMX.write(88, cRValue);
      DMX.write(89, cGValue);
      DMX.write(90, cBValue);
      DMX.write(91, aRValue);
      DMX.write(92, aGValue);
      DMX.write(93, aBValue);
      DMX.write(94, bRValue);
      DMX.write(95, bGValue);
      DMX.write(96, bBValue);
      DMX.write(97, cRValue);
      DMX.write(98, cGValue);
      DMX.write(99, cBValue);
      DMX.write(100, aRValue);
      DMX.write(101, aGValue);
      DMX.write(102, aBValue);
      DMX.write(103, bRValue);
      DMX.write(104, bGValue);
      DMX.write(105, bBValue);
      DMX.write(106, cRValue);
      DMX.write(107, cGValue);
      DMX.write(108, cBValue);
      DMX.write(109, aRValue);
      DMX.write(110, aGValue);
      DMX.write(111, aBValue);
      DMX.write(112, bRValue);
      DMX.write(113, bGValue);
      DMX.write(114, bBValue);
      DMX.write(115, cRValue);
      DMX.write(116, cGValue);
      DMX.write(117, cBValue);
      DMX.write(118, aRValue);
      DMX.write(119, aGValue);
      DMX.write(120, aBValue);
      DMX.write(121, bRValue);
      DMX.write(122, bGValue);
      DMX.write(123, bBValue);
      DMX.write(124, cRValue);
      DMX.write(125, cGValue);
      DMX.write(126, cBValue);
      DMX.write(127, aRValue);
      DMX.write(128, aGValue);
      DMX.write(129, aBValue);
      DMX.write(130, bRValue);
      DMX.write(131, bGValue);
      DMX.write(132, bBValue);
      DMX.write(133, cRValue);
      DMX.write(134, cGValue);
      DMX.write(135, cBValue);
      DMX.write(136, aRValue);
      DMX.write(137, aGValue);
      DMX.write(138, aBValue);
      DMX.write(139, bRValue);
      DMX.write(140, bGValue);
      DMX.write(141, bBValue);
      DMX.write(142, cRValue);
      DMX.write(143, cGValue);
      DMX.write(144, cBValue);
      DMX.write(145, aRValue);
      DMX.write(146, aGValue);
      DMX.write(147, aBValue);
      DMX.write(148, bRValue);
      DMX.write(149, bGValue);
      DMX.write(150, bBValue);
      DMX.write(151, cRValue);
      DMX.write(152, cGValue);
      DMX.write(153, cBValue);
      DMX.write(154, aRValue);
      DMX.write(155, aGValue);
      DMX.write(156, aBValue);
      DMX.write(157, bRValue);
      DMX.write(158, bGValue);
      DMX.write(159, bBValue);
      DMX.write(160, cRValue);
      DMX.write(161, cGValue);
      DMX.write(162, cBValue);
      DMX.write(163, aRValue);
      DMX.write(164, aGValue);
      DMX.write(165, aBValue);
      DMX.write(166, bRValue);
      DMX.write(167, bGValue);
      DMX.write(168, bBValue);
      DMX.write(169, cRValue);
      DMX.write(170, cGValue);
      DMX.write(171, cBValue);
      DMX.write(172, aRValue);
      DMX.write(173, aGValue);
      DMX.write(174, aBValue);
      DMX.write(175, bRValue);
      DMX.write(176, bGValue);
      DMX.write(177, bBValue);
      DMX.write(178, cRValue);
      DMX.write(179, cGValue);
      DMX.write(180, cBValue);



    }

  }

  else {

    power = false;


    DMX.write(1, 0);
    DMX.write(2, 0);
    DMX.write(3, 0);
    DMX.write(4, 0);
    DMX.write(5, 0);
    DMX.write(6, 0);
    DMX.write(7, 0);
    DMX.write(8, 0);
    DMX.write(9, 0);
    DMX.write(10, 0);
    DMX.write(11, 0);
    DMX.write(12, 0);
    DMX.write(13, 0);
    DMX.write(14, 0);
    DMX.write(15, 0);
    DMX.write(16, 0);
    DMX.write(17, 0);
    DMX.write(18, 0);
    DMX.write(19, 0);
    DMX.write(20, 0);
    DMX.write(21, 0);
    DMX.write(22, 0);
    DMX.write(23, 0);
    DMX.write(24, 0);
    DMX.write(25, 0);
    DMX.write(26, 0);
    DMX.write(27, 0);
    DMX.write(28, 0);
    DMX.write(29, 0);
    DMX.write(30, 0);
    DMX.write(31, 0);
    DMX.write(32, 0);
    DMX.write(33, 0);
    DMX.write(34, 0);
    DMX.write(35, 0);
    DMX.write(36, 0);
    DMX.write(37, 0);
    DMX.write(38, 0);
    DMX.write(39, 0);
    DMX.write(40, 0);
    DMX.write(41, 0);
    DMX.write(42, 0);
    DMX.write(43, 0);
    DMX.write(44, 0);
    DMX.write(45, 0);
    DMX.write(46, 0);
    DMX.write(47, 0);
    DMX.write(48, 0);
    DMX.write(49, 0);
    DMX.write(50, 0);
    DMX.write(51, 0);
    DMX.write(52, 0);
    DMX.write(53, 0);
    DMX.write(54, 0);
    DMX.write(55, 0);
    DMX.write(56, 0);
    DMX.write(57, 0);
    DMX.write(58, 0);
    DMX.write(59, 0);
    DMX.write(60, 0);
    DMX.write(61, 0);
    DMX.write(62, 0);
    DMX.write(63, 0);
    DMX.write(64, 0);
    DMX.write(65, 0);
    DMX.write(66, 0);
    DMX.write(67, 0);
    DMX.write(68, 0);
    DMX.write(69, 0);
    DMX.write(70, 0);
    DMX.write(71, 0);
    DMX.write(72, 0);
    DMX.write(73, 0);
    DMX.write(74, 0);
    DMX.write(75, 0);
    DMX.write(76, 0);
    DMX.write(77, 0);
    DMX.write(78, 0);
    DMX.write(79, 0);
    DMX.write(80, 0);
    DMX.write(81, 0);
    DMX.write(82, 0);
    DMX.write(83, 0);
    DMX.write(84, 0);
    DMX.write(85, 0);
    DMX.write(86, 0);
    DMX.write(87, 0);
    DMX.write(88, 0);
    DMX.write(89, 0);
    DMX.write(90, 0);
    DMX.write(91, 0);
    DMX.write(92, 0);
    DMX.write(93, 0);
    DMX.write(94, 0);
    DMX.write(95, 0);
    DMX.write(96, 0);
    DMX.write(97, 0);
    DMX.write(98, 0);
    DMX.write(99, 0);
    DMX.write(100, 0);
    DMX.write(101, 0);
    DMX.write(102, 0);
    DMX.write(103, 0);
    DMX.write(104, 0);
    DMX.write(105, 0);
    DMX.write(106, 0);
    DMX.write(107, 0);
    DMX.write(108, 0);
    DMX.write(109, 0);
    DMX.write(110, 0);
    DMX.write(111, 0);
    DMX.write(112, 0);
    DMX.write(113, 0);
    DMX.write(114, 0);
    DMX.write(115, 0);
    DMX.write(116, 0);
    DMX.write(117, 0);
    DMX.write(118, 0);
    DMX.write(119, 0);
    DMX.write(120, 0);
    DMX.write(121, 0);
    DMX.write(122, 0);
    DMX.write(123, 0);
    DMX.write(124, 0);
    DMX.write(125, 0);
    DMX.write(126, 0);
    DMX.write(127, 0);
    DMX.write(128, 0);
    DMX.write(129, 0);
    DMX.write(130, 0);
    DMX.write(131, 0);
    DMX.write(132, 0);
    DMX.write(133, 0);
    DMX.write(134, 0);
    DMX.write(135, 0);
    DMX.write(136, 0);
    DMX.write(137, 0);
    DMX.write(138, 0);
    DMX.write(139, 0);
    DMX.write(140, 0);
    DMX.write(141, 0);
    DMX.write(142, 0);
    DMX.write(143, 0);
    DMX.write(144, 0);
    DMX.write(145, 0);
    DMX.write(146, 0);
    DMX.write(147, 0);
    DMX.write(148, 0);
    DMX.write(149, 0);
    DMX.write(150, 0);
    DMX.write(151, 0);
    DMX.write(152, 0);
    DMX.write(153, 0);
    DMX.write(154, 0);
    DMX.write(155, 0);
    DMX.write(156, 0);
    DMX.write(157, 0);
    DMX.write(158, 0);
    DMX.write(159, 0);
    DMX.write(160, 0);
    DMX.write(161, 0);
    DMX.write(162, 0);
    DMX.write(163, 0);
    DMX.write(164, 0);
    DMX.write(165, 0);
    DMX.write(166, 0);
    DMX.write(167, 0);
    DMX.write(168, 0);
    DMX.write(169, 0);
    DMX.write(170, 0);
    DMX.write(171, 0);
    DMX.write(172, 0);
    DMX.write(173, 0);
    DMX.write(174, 0);
    DMX.write(175, 0);
    DMX.write(176, 0);
    DMX.write(177, 0);
    DMX.write(178, 0);
    DMX.write(179, 0);
    DMX.write(180, 0);



  }






  /*if (hbSched.isActive()) {
    heartbeat = true;
    digitalWrite(hbPin, HIGH);
    } else {
    heartbeat = false;
    digitalWrite(hbPin, LOW);
    }


    if (millis() - lastToggleTime >= 500) {
    lastToggleTime = millis();
    statusBState = !statusBState;
    digitalWrite(statusB, statusBState);
    }*/

  DMX.endTransmission();
}





/*
  Since Power is READ_WRITE variable, onPowerChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onPowerChange()  {
  // Add your code here to act upon Power change
}

/*
  Since AColour is READ_WRITE variable, onAColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onAColourChange()  {
  // Add your code here to act upon AColour change
}

/*
  Since BColour is READ_WRITE variable, onBColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onBColourChange()  {
  // Add your code here to act upon BColour change
}

/*
  Since CColour is READ_WRITE variable, onCColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onCColourChange()  {
  // Add your code here to act upon CColour change
}

/*
  Since Effect is READ_WRITE variable, onEffectChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onEffectChange()  {
  // Add your code here to act upon Effect change
}

/*
  Since FxSpeed is READ_WRITE variable, onFxSpeedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onFxSpeedChange()  {
  // Add your code here to act upon FxSpeed change
}

/*
  Since HbSched is READ_WRITE variable, onHbSchedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHbSchedChange()  {
  // Add your code here to act upon HbSched change
}

/*
  Since Heartbeat is READ_WRITE variable, onHeartbeatChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHeartbeatChange()  {
  // Add your code here to act upon Heartbeat change
}

/*
  Since OnTime is READ_WRITE variable, onOnTimeChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onOnTimeChange()  {
  // Add your code here to act upon OnTime change
}

/*
  Since Current is READ_WRITE variable, onCurrentChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onCurrentChange()  {
  // Add your code here to act upon Current change
}

Hi @gcjr,

Thank you very much for your message,

As you probably ascertained, the sketch allows me to control some DMX lighting from the arduino IoT service, when connected to the PC, it runs perfectly. I get almost instant feedback.

When I boot the board not connected to USB the lights come on flickering a bit the freeze, and the Board reboots, this happens over and over.

I think I am right in saying that the Arduino gets no processing support from the PC so as the code can run when connected to the PC, trying something simpler is probably not the answer? Additionally, the issue persists when I only sever the data lines to the PC, so I think this precludes electrical or circuit issues?

I have just tried Blink and this works with or without the PC.

Any other ideas would be greatly appreciated.

M

Try a delay(100); instead. Maybe the IO pins flicker on power up but the board is stuck waiting on Serial data???

Hi there @apf1979 - I have just tried this and unfortunately no help.

Any other ideas? I'll try anything at this point!

M

Hi, @apf1979, @gcjr, @camsysca, @madmark2150 and anyone else reading this....

An update...

I did find this in the code...

#include "thingProperties.h".

There is an additional '.' but removing this did not fix the issue.

However I have made some progress, I uploaded some code from a previous project and this does work. As a reminder here is the code that does not work when connected to the PC...

// Works when connected to pc, period after initproperties removed



// ArduinoDMX - Version: Latest 
#include <ArduinoDMX.h>

// ArduinoRS485 - Version: Latest 
#include <ArduinoRS485.h>

/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
  https://create.arduino.cc/cloud/things/REDACTED

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudColor aColour;
  CloudColor bColour;
  CloudColor cColour;
  int current;
  int fxSpeed;
  CloudSchedule hbSched;
  CloudSchedule onTime;
  bool effect;
  bool heartbeat;
  bool power;

  Variables which are marked as READ/WRIT
  E in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

const int hbPin = 8;
const int statusB = 3;

const int universeSize = 180;

unsigned long lastToggleTime = 0;
unsigned long lastLuxTime = 0;
bool statusBState = false;


void setup() {

Serial.begin(9600);




  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);



  pinMode(hbPin, OUTPUT);
  pinMode(statusB, OUTPUT);

  DMX.begin(universeSize);

}



void loop() {

  DMX.beginTransmission();

  ArduinoCloud.update();


  byte aRValue, aGValue, aBValue;
  byte bRValue, bGValue, bBValue;
  byte cRValue, cGValue, cBValue;

  Color aCurrentColour(aColour.getValue().hue, aColour.getValue().sat, aColour.getValue().bri);
  aCurrentColour.getRGB(aRValue, aGValue, aBValue);

  Color bCurrentColour(bColour.getValue().hue, bColour.getValue().sat, bColour.getValue().bri);
  bCurrentColour.getRGB(bRValue, bGValue, bBValue);

  Color cCurrentColour(cColour.getValue().hue, cColour.getValue().sat, cColour.getValue().bri);
  cCurrentColour.getRGB(cRValue, cGValue, cBValue);

  if (onTime.isActive()) {

    power = true;

    if (effect == 1) {

      unsigned long currentTime = millis(); // get the current time
      static unsigned long previousTime = currentTime;
      static int step = 0;

      if (currentTime - previousTime >= fxSpeed) {
        previousTime = currentTime;

        switch (step) {
          case 0:


            DMX.write(1, aRValue);
            DMX.write(2, aGValue);
            DMX.write(3, aBValue);
            DMX.write(4, bRValue);
            DMX.write(5, bGValue);
            DMX.write(6, bBValue);
            DMX.write(7, cRValue);
            DMX.write(8, cGValue);
            DMX.write(9, cBValue);
            DMX.write(10, aRValue);
            DMX.write(11, aGValue);
            DMX.write(12, aBValue);
            DMX.write(13, bRValue);
            DMX.write(14, bGValue);
            DMX.write(15, bBValue);
            DMX.write(16, cRValue);
            DMX.write(17, cGValue);
            DMX.write(18, cBValue);
            DMX.write(19, aRValue);
            DMX.write(20, aGValue);
            DMX.write(21, aBValue);
            DMX.write(22, bRValue);
            DMX.write(23, bGValue);
            DMX.write(24, bBValue);
            DMX.write(25, cRValue);
            DMX.write(26, cGValue);
            DMX.write(27, cBValue);
            DMX.write(28, aRValue);
            DMX.write(29, aGValue);
            DMX.write(30, aBValue);
            DMX.write(31, bRValue);
            DMX.write(32, bGValue);
            DMX.write(33, bBValue);
            DMX.write(34, cRValue);
            DMX.write(35, cGValue);
            DMX.write(36, cBValue);
            DMX.write(37, aRValue);
            DMX.write(38, aGValue);
            DMX.write(39, aBValue);
            DMX.write(40, bRValue);
            DMX.write(41, bGValue);
            DMX.write(42, bBValue);
            DMX.write(43, cRValue);
            DMX.write(44, cGValue);
            DMX.write(45, cBValue);
            DMX.write(46, aRValue);
            DMX.write(47, aGValue);
            DMX.write(48, aBValue);
            DMX.write(49, bRValue);
            DMX.write(50, bGValue);
            DMX.write(51, bBValue);
            DMX.write(52, cRValue);
            DMX.write(53, cGValue);
            DMX.write(54, cBValue);
            DMX.write(55, aRValue);
            DMX.write(56, aGValue);
            DMX.write(57, aBValue);
            DMX.write(58, bRValue);
            DMX.write(59, bGValue);
            DMX.write(60, bBValue);
            DMX.write(61, cRValue);
            DMX.write(62, cGValue);
            DMX.write(63, cBValue);
            DMX.write(64, aRValue);
            DMX.write(65, aGValue);
            DMX.write(66, aBValue);
            DMX.write(67, bRValue);
            DMX.write(68, bGValue);
            DMX.write(69, bBValue);
            DMX.write(70, cRValue);
            DMX.write(71, cGValue);
            DMX.write(72, cBValue);
            DMX.write(73, aRValue);
            DMX.write(74, aGValue);
            DMX.write(75, aBValue);
            DMX.write(76, bRValue);
            DMX.write(77, bGValue);
            DMX.write(78, bBValue);
            DMX.write(79, cRValue);
            DMX.write(80, cGValue);
            DMX.write(81, cBValue);
            DMX.write(82, aRValue);
            DMX.write(83, aGValue);
            DMX.write(84, aBValue);
            DMX.write(85, bRValue);
            DMX.write(86, bGValue);
            DMX.write(87, bBValue);
            DMX.write(88, cRValue);
            DMX.write(89, cGValue);
            DMX.write(90, cBValue);
            DMX.write(91, aRValue);
            DMX.write(92, aGValue);
            DMX.write(93, aBValue);
            DMX.write(94, bRValue);
            DMX.write(95, bGValue);
            DMX.write(96, bBValue);
            DMX.write(97, cRValue);
            DMX.write(98, cGValue);
            DMX.write(99, cBValue);
            DMX.write(100, aRValue);
            DMX.write(101, aGValue);
            DMX.write(102, aBValue);
            DMX.write(103, bRValue);
            DMX.write(104, bGValue);
            DMX.write(105, bBValue);
            DMX.write(106, cRValue);
            DMX.write(107, cGValue);
            DMX.write(108, cBValue);
            DMX.write(109, aRValue);
            DMX.write(110, aGValue);
            DMX.write(111, aBValue);
            DMX.write(112, bRValue);
            DMX.write(113, bGValue);
            DMX.write(114, bBValue);
            DMX.write(115, cRValue);
            DMX.write(116, cGValue);
            DMX.write(117, cBValue);
            DMX.write(118, aRValue);
            DMX.write(119, aGValue);
            DMX.write(120, aBValue);
            DMX.write(121, bRValue);
            DMX.write(122, bGValue);
            DMX.write(123, bBValue);
            DMX.write(124, cRValue);
            DMX.write(125, cGValue);
            DMX.write(126, cBValue);
            DMX.write(127, aRValue);
            DMX.write(128, aGValue);
            DMX.write(129, aBValue);
            DMX.write(130, bRValue);
            DMX.write(131, bGValue);
            DMX.write(132, bBValue);
            DMX.write(133, cRValue);
            DMX.write(134, cGValue);
            DMX.write(135, cBValue);
            DMX.write(136, aRValue);
            DMX.write(137, aGValue);
            DMX.write(138, aBValue);
            DMX.write(139, bRValue);
            DMX.write(140, bGValue);
            DMX.write(141, bBValue);
            DMX.write(142, cRValue);
            DMX.write(143, cGValue);
            DMX.write(144, cBValue);
            DMX.write(145, aRValue);
            DMX.write(146, aGValue);
            DMX.write(147, aBValue);
            DMX.write(148, bRValue);
            DMX.write(149, bGValue);
            DMX.write(150, bBValue);
            DMX.write(151, cRValue);
            DMX.write(152, cGValue);
            DMX.write(153, cBValue);
            DMX.write(154, aRValue);
            DMX.write(155, aGValue);
            DMX.write(156, aBValue);
            DMX.write(157, bRValue);
            DMX.write(158, bGValue);
            DMX.write(159, bBValue);
            DMX.write(160, cRValue);
            DMX.write(161, cGValue);
            DMX.write(162, cBValue);
            DMX.write(163, aRValue);
            DMX.write(164, aGValue);
            DMX.write(165, aBValue);
            DMX.write(166, bRValue);
            DMX.write(167, bGValue);
            DMX.write(168, bBValue);
            DMX.write(169, cRValue);
            DMX.write(170, cGValue);
            DMX.write(171, cBValue);
            DMX.write(172, aRValue);
            DMX.write(173, aGValue);
            DMX.write(174, aBValue);
            DMX.write(175, bRValue);
            DMX.write(176, bGValue);
            DMX.write(177, bBValue);
            DMX.write(178, cRValue);
            DMX.write(179, cGValue);
            DMX.write(180, cBValue);




            break;

          case 1:




            DMX.write(1, cRValue);
            DMX.write(2, cGValue);
            DMX.write(3, cBValue);
            DMX.write(4, aRValue);
            DMX.write(5, aGValue);
            DMX.write(6, aBValue);
            DMX.write(7, bRValue);
            DMX.write(8, bGValue);
            DMX.write(9, bBValue);
            DMX.write(10, cRValue);
            DMX.write(11, cGValue);
            DMX.write(12, cBValue);
            DMX.write(13, aRValue);
            DMX.write(14, aGValue);
            DMX.write(15, aBValue);
            DMX.write(16, bRValue);
            DMX.write(17, bGValue);
            DMX.write(18, bBValue);
            DMX.write(19, cRValue);
            DMX.write(20, cGValue);
            DMX.write(21, cBValue);
            DMX.write(22, aRValue);
            DMX.write(23, aGValue);
            DMX.write(24, aBValue);
            DMX.write(25, bRValue);
            DMX.write(26, bGValue);
            DMX.write(27, bBValue);
            DMX.write(28, cRValue);
            DMX.write(29, cGValue);
            DMX.write(30, cBValue);
            DMX.write(31, aRValue);
            DMX.write(32, aGValue);
            DMX.write(33, aBValue);
            DMX.write(34, bRValue);
            DMX.write(35, bGValue);
            DMX.write(36, bBValue);
            DMX.write(37, cRValue);
            DMX.write(38, cGValue);
            DMX.write(39, cBValue);
            DMX.write(40, aRValue);
            DMX.write(41, aGValue);
            DMX.write(42, aBValue);
            DMX.write(43, bRValue);
            DMX.write(44, bGValue);
            DMX.write(45, bBValue);
            DMX.write(46, cRValue);
            DMX.write(47, cGValue);
            DMX.write(48, cBValue);
            DMX.write(49, aRValue);
            DMX.write(50, aGValue);
            DMX.write(51, aBValue);
            DMX.write(52, bRValue);
            DMX.write(53, bGValue);
            DMX.write(54, bBValue);
            DMX.write(55, cRValue);
            DMX.write(56, cGValue);
            DMX.write(57, cBValue);
            DMX.write(58, aRValue);
            DMX.write(59, aGValue);
            DMX.write(60, aBValue);
            DMX.write(61, bRValue);
            DMX.write(62, bGValue);
            DMX.write(63, bBValue);
            DMX.write(64, cRValue);
            DMX.write(65, cGValue);
            DMX.write(66, cBValue);
            DMX.write(67, aRValue);
            DMX.write(68, aGValue);
            DMX.write(69, aBValue);
            DMX.write(70, bRValue);
            DMX.write(71, bGValue);
            DMX.write(72, bBValue);
            DMX.write(73, cRValue);
            DMX.write(74, cGValue);
            DMX.write(75, cBValue);
            DMX.write(76, aRValue);
            DMX.write(77, aGValue);
            DMX.write(78, aBValue);
            DMX.write(79, bRValue);
            DMX.write(80, bGValue);
            DMX.write(81, bBValue);
            DMX.write(82, cRValue);
            DMX.write(83, cGValue);
            DMX.write(84, cBValue);
            DMX.write(85, aRValue);
            DMX.write(86, aGValue);
            DMX.write(87, aBValue);
            DMX.write(88, bRValue);
            DMX.write(89, bGValue);
            DMX.write(90, bBValue);
            DMX.write(91, cRValue);
            DMX.write(92, cGValue);
            DMX.write(93, cBValue);
            DMX.write(94, aRValue);
            DMX.write(95, aGValue);
            DMX.write(96, aBValue);
            DMX.write(97, bRValue);
            DMX.write(98, bGValue);
            DMX.write(99, bBValue);
            DMX.write(100, cRValue);
            DMX.write(101, cGValue);
            DMX.write(102, cBValue);
            DMX.write(103, aRValue);
            DMX.write(104, aGValue);
            DMX.write(105, aBValue);
            DMX.write(106, bRValue);
            DMX.write(107, bGValue);
            DMX.write(108, bBValue);
            DMX.write(109, cRValue);
            DMX.write(110, cGValue);
            DMX.write(111, cBValue);
            DMX.write(112, aRValue);
            DMX.write(113, aGValue);
            DMX.write(114, aBValue);
            DMX.write(115, bRValue);
            DMX.write(116, bGValue);
            DMX.write(117, bBValue);
            DMX.write(118, cRValue);
            DMX.write(119, cGValue);
            DMX.write(120, cBValue);
            DMX.write(121, aRValue);
            DMX.write(122, aGValue);
            DMX.write(123, aBValue);
            DMX.write(124, bRValue);
            DMX.write(125, bGValue);
            DMX.write(126, bBValue);
            DMX.write(127, cRValue);
            DMX.write(128, cGValue);
            DMX.write(129, cBValue);
            DMX.write(130, aRValue);
            DMX.write(131, aGValue);
            DMX.write(132, aBValue);
            DMX.write(133, bRValue);
            DMX.write(134, bGValue);
            DMX.write(135, bBValue);
            DMX.write(136, cRValue);
            DMX.write(137, cGValue);
            DMX.write(138, cBValue);
            DMX.write(139, aRValue);
            DMX.write(140, aGValue);
            DMX.write(141, aBValue);
            DMX.write(142, bRValue);
            DMX.write(143, bGValue);
            DMX.write(144, bBValue);
            DMX.write(145, cRValue);
            DMX.write(146, cGValue);
            DMX.write(147, cBValue);
            DMX.write(148, aRValue);
            DMX.write(149, aGValue);
            DMX.write(150, aBValue);
            DMX.write(151, bRValue);
            DMX.write(152, bGValue);
            DMX.write(153, bBValue);
            DMX.write(154, cRValue);
            DMX.write(155, cGValue);
            DMX.write(156, cBValue);
            DMX.write(157, aRValue);
            DMX.write(158, aGValue);
            DMX.write(159, aBValue);
            DMX.write(160, bRValue);
            DMX.write(161, bGValue);
            DMX.write(162, bBValue);
            DMX.write(163, cRValue);
            DMX.write(164, cGValue);
            DMX.write(165, cBValue);
            DMX.write(166, aRValue);
            DMX.write(167, aGValue);
            DMX.write(168, aBValue);
            DMX.write(169, bRValue);
            DMX.write(170, bGValue);
            DMX.write(171, bBValue);
            DMX.write(172, cRValue);
            DMX.write(173, cGValue);
            DMX.write(174, cBValue);
            DMX.write(175, aRValue);
            DMX.write(176, aGValue);
            DMX.write(177, aBValue);
            DMX.write(178, bRValue);
            DMX.write(179, bGValue);
            DMX.write(180, bBValue);



            break;

          case 2:



            DMX.write(1, bRValue);
            DMX.write(2, bGValue);
            DMX.write(3, bBValue);
            DMX.write(4, cRValue);
            DMX.write(5, cGValue);
            DMX.write(6, cBValue);
            DMX.write(7, aRValue);
            DMX.write(8, aGValue);
            DMX.write(9, aBValue);
            DMX.write(10, bRValue);
            DMX.write(11, bGValue);
            DMX.write(12, bBValue);
            DMX.write(13, cRValue);
            DMX.write(14, cGValue);
            DMX.write(15, cBValue);
            DMX.write(16, aRValue);
            DMX.write(17, aGValue);
            DMX.write(18, aBValue);
            DMX.write(19, bRValue);
            DMX.write(20, bGValue);
            DMX.write(21, bBValue);
            DMX.write(22, cRValue);
            DMX.write(23, cGValue);
            DMX.write(24, cBValue);
            DMX.write(25, aRValue);
            DMX.write(26, aGValue);
            DMX.write(27, aBValue);
            DMX.write(28, bRValue);
            DMX.write(29, bGValue);
            DMX.write(30, bBValue);
            DMX.write(31, cRValue);
            DMX.write(32, cGValue);
            DMX.write(33, cBValue);
            DMX.write(34, aRValue);
            DMX.write(35, aGValue);
            DMX.write(36, aBValue);
            DMX.write(37, bRValue);
            DMX.write(38, bGValue);
            DMX.write(39, bBValue);
            DMX.write(40, cRValue);
            DMX.write(41, cGValue);
            DMX.write(42, cBValue);
            DMX.write(43, aRValue);
            DMX.write(44, aGValue);
            DMX.write(45, aBValue);
            DMX.write(46, bRValue);
            DMX.write(47, bGValue);
            DMX.write(48, bBValue);
            DMX.write(49, cRValue);
            DMX.write(50, cGValue);
            DMX.write(51, cBValue);
            DMX.write(52, aRValue);
            DMX.write(53, aGValue);
            DMX.write(54, aBValue);
            DMX.write(55, bRValue);
            DMX.write(56, bGValue);
            DMX.write(57, bBValue);
            DMX.write(58, cRValue);
            DMX.write(59, cGValue);
            DMX.write(60, cBValue);
            DMX.write(61, aRValue);
            DMX.write(62, aGValue);
            DMX.write(63, aBValue);
            DMX.write(64, bRValue);
            DMX.write(65, bGValue);
            DMX.write(66, bBValue);
            DMX.write(67, cRValue);
            DMX.write(68, cGValue);
            DMX.write(69, cBValue);
            DMX.write(70, aRValue);
            DMX.write(71, aGValue);
            DMX.write(72, aBValue);
            DMX.write(73, bRValue);
            DMX.write(74, bGValue);
            DMX.write(75, bBValue);
            DMX.write(76, cRValue);
            DMX.write(77, cGValue);
            DMX.write(78, cBValue);
            DMX.write(79, aRValue);
            DMX.write(80, aGValue);
            DMX.write(81, aBValue);
            DMX.write(82, bRValue);
            DMX.write(83, bGValue);
            DMX.write(84, bBValue);
            DMX.write(85, cRValue);
            DMX.write(86, cGValue);
            DMX.write(87, cBValue);
            DMX.write(88, aRValue);
            DMX.write(89, aGValue);
            DMX.write(90, aBValue);
            DMX.write(91, bRValue);
            DMX.write(92, bGValue);
            DMX.write(93, bBValue);
            DMX.write(94, cRValue);
            DMX.write(95, cGValue);
            DMX.write(96, cBValue);
            DMX.write(97, aRValue);
            DMX.write(98, aGValue);
            DMX.write(99, aBValue);
            DMX.write(100, bRValue);
            DMX.write(101, bGValue);
            DMX.write(102, bBValue);
            DMX.write(103, cRValue);
            DMX.write(104, cGValue);
            DMX.write(105, cBValue);
            DMX.write(106, aRValue);
            DMX.write(107, aGValue);
            DMX.write(108, aBValue);
            DMX.write(109, bRValue);
            DMX.write(110, bGValue);
            DMX.write(111, bBValue);
            DMX.write(112, cRValue);
            DMX.write(113, cGValue);
            DMX.write(114, cBValue);
            DMX.write(115, aRValue);
            DMX.write(116, aGValue);
            DMX.write(117, aBValue);
            DMX.write(118, bRValue);
            DMX.write(119, bGValue);
            DMX.write(120, bBValue);
            DMX.write(121, cRValue);
            DMX.write(122, cGValue);
            DMX.write(123, cBValue);
            DMX.write(124, aRValue);
            DMX.write(125, aGValue);
            DMX.write(126, aBValue);
            DMX.write(127, bRValue);
            DMX.write(128, bGValue);
            DMX.write(129, bBValue);
            DMX.write(130, cRValue);
            DMX.write(131, cGValue);
            DMX.write(132, cBValue);
            DMX.write(133, aRValue);
            DMX.write(134, aGValue);
            DMX.write(135, aBValue);
            DMX.write(136, bRValue);
            DMX.write(137, bGValue);
            DMX.write(138, bBValue);
            DMX.write(139, cRValue);
            DMX.write(140, cGValue);
            DMX.write(141, cBValue);
            DMX.write(142, aRValue);
            DMX.write(143, aGValue);
            DMX.write(144, aBValue);
            DMX.write(145, bRValue);
            DMX.write(146, bGValue);
            DMX.write(147, bBValue);
            DMX.write(148, cRValue);
            DMX.write(149, cGValue);
            DMX.write(150, cBValue);
            DMX.write(151, aRValue);
            DMX.write(152, aGValue);
            DMX.write(153, aBValue);
            DMX.write(154, bRValue);
            DMX.write(155, bGValue);
            DMX.write(156, bBValue);
            DMX.write(157, cRValue);
            DMX.write(158, cGValue);
            DMX.write(159, cBValue);
            DMX.write(160, aRValue);
            DMX.write(161, aGValue);
            DMX.write(162, aBValue);
            DMX.write(163, bRValue);
            DMX.write(164, bGValue);
            DMX.write(165, bBValue);
            DMX.write(166, cRValue);
            DMX.write(167, cGValue);
            DMX.write(168, cBValue);
            DMX.write(169, aRValue);
            DMX.write(170, aGValue);
            DMX.write(171, aBValue);
            DMX.write(172, bRValue);
            DMX.write(173, bGValue);
            DMX.write(174, bBValue);
            DMX.write(175, cRValue);
            DMX.write(176, cGValue);
            DMX.write(177, cBValue);
            DMX.write(178, aRValue);
            DMX.write(179, aGValue);
            DMX.write(180, aBValue);



            break;
        }

        step++;
        if (step > 2) {
          step = 0;
        }
      }

    } else {


      DMX.write(1, aRValue);
      DMX.write(2, aGValue);
      DMX.write(3, aBValue);
      DMX.write(4, bRValue);
      DMX.write(5, bGValue);
      DMX.write(6, bBValue);
      DMX.write(7, cRValue);
      DMX.write(8, cGValue);
      DMX.write(9, cBValue);
      DMX.write(10, aRValue);
      DMX.write(11, aGValue);
      DMX.write(12, aBValue);
      DMX.write(13, bRValue);
      DMX.write(14, bGValue);
      DMX.write(15, bBValue);
      DMX.write(16, cRValue);
      DMX.write(17, cGValue);
      DMX.write(18, cBValue);
      DMX.write(19, aRValue);
      DMX.write(20, aGValue);
      DMX.write(21, aBValue);
      DMX.write(22, bRValue);
      DMX.write(23, bGValue);
      DMX.write(24, bBValue);
      DMX.write(25, cRValue);
      DMX.write(26, cGValue);
      DMX.write(27, cBValue);
      DMX.write(28, aRValue);
      DMX.write(29, aGValue);
      DMX.write(30, aBValue);
      DMX.write(31, bRValue);
      DMX.write(32, bGValue);
      DMX.write(33, bBValue);
      DMX.write(34, cRValue);
      DMX.write(35, cGValue);
      DMX.write(36, cBValue);
      DMX.write(37, aRValue);
      DMX.write(38, aGValue);
      DMX.write(39, aBValue);
      DMX.write(40, bRValue);
      DMX.write(41, bGValue);
      DMX.write(42, bBValue);
      DMX.write(43, cRValue);
      DMX.write(44, cGValue);
      DMX.write(45, cBValue);
      DMX.write(46, aRValue);
      DMX.write(47, aGValue);
      DMX.write(48, aBValue);
      DMX.write(49, bRValue);
      DMX.write(50, bGValue);
      DMX.write(51, bBValue);
      DMX.write(52, cRValue);
      DMX.write(53, cGValue);
      DMX.write(54, cBValue);
      DMX.write(55, aRValue);
      DMX.write(56, aGValue);
      DMX.write(57, aBValue);
      DMX.write(58, bRValue);
      DMX.write(59, bGValue);
      DMX.write(60, bBValue);
      DMX.write(61, cRValue);
      DMX.write(62, cGValue);
      DMX.write(63, cBValue);
      DMX.write(64, aRValue);
      DMX.write(65, aGValue);
      DMX.write(66, aBValue);
      DMX.write(67, bRValue);
      DMX.write(68, bGValue);
      DMX.write(69, bBValue);
      DMX.write(70, cRValue);
      DMX.write(71, cGValue);
      DMX.write(72, cBValue);
      DMX.write(73, aRValue);
      DMX.write(74, aGValue);
      DMX.write(75, aBValue);
      DMX.write(76, bRValue);
      DMX.write(77, bGValue);
      DMX.write(78, bBValue);
      DMX.write(79, cRValue);
      DMX.write(80, cGValue);
      DMX.write(81, cBValue);
      DMX.write(82, aRValue);
      DMX.write(83, aGValue);
      DMX.write(84, aBValue);
      DMX.write(85, bRValue);
      DMX.write(86, bGValue);
      DMX.write(87, bBValue);
      DMX.write(88, cRValue);
      DMX.write(89, cGValue);
      DMX.write(90, cBValue);
      DMX.write(91, aRValue);
      DMX.write(92, aGValue);
      DMX.write(93, aBValue);
      DMX.write(94, bRValue);
      DMX.write(95, bGValue);
      DMX.write(96, bBValue);
      DMX.write(97, cRValue);
      DMX.write(98, cGValue);
      DMX.write(99, cBValue);
      DMX.write(100, aRValue);
      DMX.write(101, aGValue);
      DMX.write(102, aBValue);
      DMX.write(103, bRValue);
      DMX.write(104, bGValue);
      DMX.write(105, bBValue);
      DMX.write(106, cRValue);
      DMX.write(107, cGValue);
      DMX.write(108, cBValue);
      DMX.write(109, aRValue);
      DMX.write(110, aGValue);
      DMX.write(111, aBValue);
      DMX.write(112, bRValue);
      DMX.write(113, bGValue);
      DMX.write(114, bBValue);
      DMX.write(115, cRValue);
      DMX.write(116, cGValue);
      DMX.write(117, cBValue);
      DMX.write(118, aRValue);
      DMX.write(119, aGValue);
      DMX.write(120, aBValue);
      DMX.write(121, bRValue);
      DMX.write(122, bGValue);
      DMX.write(123, bBValue);
      DMX.write(124, cRValue);
      DMX.write(125, cGValue);
      DMX.write(126, cBValue);
      DMX.write(127, aRValue);
      DMX.write(128, aGValue);
      DMX.write(129, aBValue);
      DMX.write(130, bRValue);
      DMX.write(131, bGValue);
      DMX.write(132, bBValue);
      DMX.write(133, cRValue);
      DMX.write(134, cGValue);
      DMX.write(135, cBValue);
      DMX.write(136, aRValue);
      DMX.write(137, aGValue);
      DMX.write(138, aBValue);
      DMX.write(139, bRValue);
      DMX.write(140, bGValue);
      DMX.write(141, bBValue);
      DMX.write(142, cRValue);
      DMX.write(143, cGValue);
      DMX.write(144, cBValue);
      DMX.write(145, aRValue);
      DMX.write(146, aGValue);
      DMX.write(147, aBValue);
      DMX.write(148, bRValue);
      DMX.write(149, bGValue);
      DMX.write(150, bBValue);
      DMX.write(151, cRValue);
      DMX.write(152, cGValue);
      DMX.write(153, cBValue);
      DMX.write(154, aRValue);
      DMX.write(155, aGValue);
      DMX.write(156, aBValue);
      DMX.write(157, bRValue);
      DMX.write(158, bGValue);
      DMX.write(159, bBValue);
      DMX.write(160, cRValue);
      DMX.write(161, cGValue);
      DMX.write(162, cBValue);
      DMX.write(163, aRValue);
      DMX.write(164, aGValue);
      DMX.write(165, aBValue);
      DMX.write(166, bRValue);
      DMX.write(167, bGValue);
      DMX.write(168, bBValue);
      DMX.write(169, cRValue);
      DMX.write(170, cGValue);
      DMX.write(171, cBValue);
      DMX.write(172, aRValue);
      DMX.write(173, aGValue);
      DMX.write(174, aBValue);
      DMX.write(175, bRValue);
      DMX.write(176, bGValue);
      DMX.write(177, bBValue);
      DMX.write(178, cRValue);
      DMX.write(179, cGValue);
      DMX.write(180, cBValue);



    }

  }

  else {

    power = false;


    DMX.write(1, 0);
    DMX.write(2, 0);
    DMX.write(3, 0);
    DMX.write(4, 0);
    DMX.write(5, 0);
    DMX.write(6, 0);
    DMX.write(7, 0);
    DMX.write(8, 0);
    DMX.write(9, 0);
    DMX.write(10, 0);
    DMX.write(11, 0);
    DMX.write(12, 0);
    DMX.write(13, 0);
    DMX.write(14, 0);
    DMX.write(15, 0);
    DMX.write(16, 0);
    DMX.write(17, 0);
    DMX.write(18, 0);
    DMX.write(19, 0);
    DMX.write(20, 0);
    DMX.write(21, 0);
    DMX.write(22, 0);
    DMX.write(23, 0);
    DMX.write(24, 0);
    DMX.write(25, 0);
    DMX.write(26, 0);
    DMX.write(27, 0);
    DMX.write(28, 0);
    DMX.write(29, 0);
    DMX.write(30, 0);
    DMX.write(31, 0);
    DMX.write(32, 0);
    DMX.write(33, 0);
    DMX.write(34, 0);
    DMX.write(35, 0);
    DMX.write(36, 0);
    DMX.write(37, 0);
    DMX.write(38, 0);
    DMX.write(39, 0);
    DMX.write(40, 0);
    DMX.write(41, 0);
    DMX.write(42, 0);
    DMX.write(43, 0);
    DMX.write(44, 0);
    DMX.write(45, 0);
    DMX.write(46, 0);
    DMX.write(47, 0);
    DMX.write(48, 0);
    DMX.write(49, 0);
    DMX.write(50, 0);
    DMX.write(51, 0);
    DMX.write(52, 0);
    DMX.write(53, 0);
    DMX.write(54, 0);
    DMX.write(55, 0);
    DMX.write(56, 0);
    DMX.write(57, 0);
    DMX.write(58, 0);
    DMX.write(59, 0);
    DMX.write(60, 0);
    DMX.write(61, 0);
    DMX.write(62, 0);
    DMX.write(63, 0);
    DMX.write(64, 0);
    DMX.write(65, 0);
    DMX.write(66, 0);
    DMX.write(67, 0);
    DMX.write(68, 0);
    DMX.write(69, 0);
    DMX.write(70, 0);
    DMX.write(71, 0);
    DMX.write(72, 0);
    DMX.write(73, 0);
    DMX.write(74, 0);
    DMX.write(75, 0);
    DMX.write(76, 0);
    DMX.write(77, 0);
    DMX.write(78, 0);
    DMX.write(79, 0);
    DMX.write(80, 0);
    DMX.write(81, 0);
    DMX.write(82, 0);
    DMX.write(83, 0);
    DMX.write(84, 0);
    DMX.write(85, 0);
    DMX.write(86, 0);
    DMX.write(87, 0);
    DMX.write(88, 0);
    DMX.write(89, 0);
    DMX.write(90, 0);
    DMX.write(91, 0);
    DMX.write(92, 0);
    DMX.write(93, 0);
    DMX.write(94, 0);
    DMX.write(95, 0);
    DMX.write(96, 0);
    DMX.write(97, 0);
    DMX.write(98, 0);
    DMX.write(99, 0);
    DMX.write(100, 0);
    DMX.write(101, 0);
    DMX.write(102, 0);
    DMX.write(103, 0);
    DMX.write(104, 0);
    DMX.write(105, 0);
    DMX.write(106, 0);
    DMX.write(107, 0);
    DMX.write(108, 0);
    DMX.write(109, 0);
    DMX.write(110, 0);
    DMX.write(111, 0);
    DMX.write(112, 0);
    DMX.write(113, 0);
    DMX.write(114, 0);
    DMX.write(115, 0);
    DMX.write(116, 0);
    DMX.write(117, 0);
    DMX.write(118, 0);
    DMX.write(119, 0);
    DMX.write(120, 0);
    DMX.write(121, 0);
    DMX.write(122, 0);
    DMX.write(123, 0);
    DMX.write(124, 0);
    DMX.write(125, 0);
    DMX.write(126, 0);
    DMX.write(127, 0);
    DMX.write(128, 0);
    DMX.write(129, 0);
    DMX.write(130, 0);
    DMX.write(131, 0);
    DMX.write(132, 0);
    DMX.write(133, 0);
    DMX.write(134, 0);
    DMX.write(135, 0);
    DMX.write(136, 0);
    DMX.write(137, 0);
    DMX.write(138, 0);
    DMX.write(139, 0);
    DMX.write(140, 0);
    DMX.write(141, 0);
    DMX.write(142, 0);
    DMX.write(143, 0);
    DMX.write(144, 0);
    DMX.write(145, 0);
    DMX.write(146, 0);
    DMX.write(147, 0);
    DMX.write(148, 0);
    DMX.write(149, 0);
    DMX.write(150, 0);
    DMX.write(151, 0);
    DMX.write(152, 0);
    DMX.write(153, 0);
    DMX.write(154, 0);
    DMX.write(155, 0);
    DMX.write(156, 0);
    DMX.write(157, 0);
    DMX.write(158, 0);
    DMX.write(159, 0);
    DMX.write(160, 0);
    DMX.write(161, 0);
    DMX.write(162, 0);
    DMX.write(163, 0);
    DMX.write(164, 0);
    DMX.write(165, 0);
    DMX.write(166, 0);
    DMX.write(167, 0);
    DMX.write(168, 0);
    DMX.write(169, 0);
    DMX.write(170, 0);
    DMX.write(171, 0);
    DMX.write(172, 0);
    DMX.write(173, 0);
    DMX.write(174, 0);
    DMX.write(175, 0);
    DMX.write(176, 0);
    DMX.write(177, 0);
    DMX.write(178, 0);
    DMX.write(179, 0);
    DMX.write(180, 0);



  }






  /*if (hbSched.isActive()) {
    heartbeat = true;
    digitalWrite(hbPin, HIGH);
    } else {
    heartbeat = false;
    digitalWrite(hbPin, LOW);
    }


    if (millis() - lastToggleTime >= 500) {
    lastToggleTime = millis();
    statusBState = !statusBState;
    digitalWrite(statusB, statusBState);
    }*/

  DMX.endTransmission();
}





/*
  Since Power is READ_WRITE variable, onPowerChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onPowerChange()  {
  // Add your code here to act upon Power change
}

/*
  Since AColour is READ_WRITE variable, onAColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onAColourChange()  {
  // Add your code here to act upon AColour change
}

/*
  Since BColour is READ_WRITE variable, onBColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onBColourChange()  {
  // Add your code here to act upon BColour change
}

/*
  Since CColour is READ_WRITE variable, onCColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onCColourChange()  {
  // Add your code here to act upon CColour change
}

/*
  Since Effect is READ_WRITE variable, onEffectChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onEffectChange()  {
  // Add your code here to act upon Effect change
}

/*
  Since FxSpeed is READ_WRITE variable, onFxSpeedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onFxSpeedChange()  {
  // Add your code here to act upon FxSpeed change
}

/*
  Since HbSched is READ_WRITE variable, onHbSchedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHbSchedChange()  {
  // Add your code here to act upon HbSched change
}

/*
  Since Heartbeat is READ_WRITE variable, onHeartbeatChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHeartbeatChange()  {
  // Add your code here to act upon Heartbeat change
}

/*
  Since OnTime is READ_WRITE variable, onOnTimeChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onOnTimeChange()  {
  // Add your code here to act upon OnTime change
}

/*
  Since Current is READ_WRITE variable, onCurrentChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onCurrentChange()  {
  // Add your code here to act upon Current change
}

And here is the code that does work when not connected to the PC.

//works but has additional status pins etc


/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
  https://create.arduino.cc/cloud/things/REDACTED

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudColor aColour;
  CloudColor bColour;
  CloudColor cColour;
  int current;
  int fxSpeed;
  CloudSchedule hbSched;
  CloudSchedule onTime;
  bool effect;
  bool heartbeat;
  bool power;

  Variables which are marked as READ/WRIT
  E in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

// ArduinoRS485 - Version: Latest 
#include <ArduinoRS485.h>

// ArduinoDMX - Version: Latest 
#include <ArduinoDMX.h>

#include "thingProperties.h".

const int hbPin = 8;
const int statusA = 2;
const int statusB = 3;
const int statusC = 4;
const int luxPin = A3;

const int universeSize = 180;



unsigned long lastToggleTime = 0;
unsigned long lastLuxTime = 0;
bool statusBState = false;


void setup() {
  
  Serial.begin(9600);

  initProperties();

  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  pinMode(hbPin, OUTPUT);
  pinMode(statusA, OUTPUT);
  pinMode(statusB, OUTPUT);
  pinMode(statusC, OUTPUT);
  pinMode(luxPin, INPUT);

  DMX.begin(universeSize);
 
  }



void loop() {
  
  ArduinoCloud.update();
  dmxLoop();
  checkHeartbeat();
  toggleStatusB();
  luxLoop();
}

void dmxLoop() {
  

byte aRValue, aGValue, aBValue;
byte bRValue, bGValue, bBValue;
byte cRValue, cGValue, cBValue;

  Color aCurrentColour(aColour.getValue().hue, aColour.getValue().sat, aColour.getValue().bri);
  aCurrentColour.getRGB(aRValue, aGValue, aBValue);

  Color bCurrentColour(bColour.getValue().hue, bColour.getValue().sat, bColour.getValue().bri);
  bCurrentColour.getRGB(bRValue, bGValue, bBValue);

  Color cCurrentColour(cColour.getValue().hue, cColour.getValue().sat, cColour.getValue().bri);
  cCurrentColour.getRGB(cRValue, cGValue, cBValue);
  
 if (onTime.isActive()) {
  
    power = true;
    
    digitalWrite(statusC, HIGH);
    
    if (effect == 1) {
        
      unsigned long currentTime = millis(); // get the current time
      static unsigned long previousTime = currentTime;
      static int step = 0;
      
      if (currentTime - previousTime >= fxSpeed) {
        previousTime = currentTime;
        
          switch(step) {
          case 0:
          
          DMX.beginTransmission();
          DMX.write(1, aRValue);
DMX.write(2, aGValue);
DMX.write(3, aBValue);
DMX.write(4, bRValue);
DMX.write(5, bGValue);
DMX.write(6, bBValue);
DMX.write(7, cRValue);
DMX.write(8, cGValue);
DMX.write(9, cBValue);
DMX.write(10, aRValue);
DMX.write(11, aGValue);
DMX.write(12, aBValue);
DMX.write(13, bRValue);
DMX.write(14, bGValue);
DMX.write(15, bBValue);
DMX.write(16, cRValue);
DMX.write(17, cGValue);
DMX.write(18, cBValue);
DMX.write(19, aRValue);
DMX.write(20, aGValue);
DMX.write(21, aBValue);
DMX.write(22, bRValue);
DMX.write(23, bGValue);
DMX.write(24, bBValue);
DMX.write(25, cRValue);
DMX.write(26, cGValue);
DMX.write(27, cBValue);
DMX.write(28, aRValue);
DMX.write(29, aGValue);
DMX.write(30, aBValue);
DMX.write(31, bRValue);
DMX.write(32, bGValue);
DMX.write(33, bBValue);
DMX.write(34, cRValue);
DMX.write(35, cGValue);
DMX.write(36, cBValue);
DMX.write(37, aRValue);
DMX.write(38, aGValue);
DMX.write(39, aBValue);
DMX.write(40, bRValue);
DMX.write(41, bGValue);
DMX.write(42, bBValue);
DMX.write(43, cRValue);
DMX.write(44, cGValue);
DMX.write(45, cBValue);
DMX.write(46, aRValue);
DMX.write(47, aGValue);
DMX.write(48, aBValue);
DMX.write(49, bRValue);
DMX.write(50, bGValue);
DMX.write(51, bBValue);
DMX.write(52, cRValue);
DMX.write(53, cGValue);
DMX.write(54, cBValue);
DMX.write(55, aRValue);
DMX.write(56, aGValue);
DMX.write(57, aBValue);
DMX.write(58, bRValue);
DMX.write(59, bGValue);
DMX.write(60, bBValue);
DMX.write(61, cRValue);
DMX.write(62, cGValue);
DMX.write(63, cBValue);
DMX.write(64, aRValue);
DMX.write(65, aGValue);
DMX.write(66, aBValue);
DMX.write(67, bRValue);
DMX.write(68, bGValue);
DMX.write(69, bBValue);
DMX.write(70, cRValue);
DMX.write(71, cGValue);
DMX.write(72, cBValue);
DMX.write(73, aRValue);
DMX.write(74, aGValue);
DMX.write(75, aBValue);
DMX.write(76, bRValue);
DMX.write(77, bGValue);
DMX.write(78, bBValue);
DMX.write(79, cRValue);
DMX.write(80, cGValue);
DMX.write(81, cBValue);
DMX.write(82, aRValue);
DMX.write(83, aGValue);
DMX.write(84, aBValue);
DMX.write(85, bRValue);
DMX.write(86, bGValue);
DMX.write(87, bBValue);
DMX.write(88, cRValue);
DMX.write(89, cGValue);
DMX.write(90, cBValue);
DMX.write(91, aRValue);
DMX.write(92, aGValue);
DMX.write(93, aBValue);
DMX.write(94, bRValue);
DMX.write(95, bGValue);
DMX.write(96, bBValue);
DMX.write(97, cRValue);
DMX.write(98, cGValue);
DMX.write(99, cBValue);
DMX.write(100, aRValue);
DMX.write(101, aGValue);
DMX.write(102, aBValue);
DMX.write(103, bRValue);
DMX.write(104, bGValue);
DMX.write(105, bBValue);
DMX.write(106, cRValue);
DMX.write(107, cGValue);
DMX.write(108, cBValue);
DMX.write(109, aRValue);
DMX.write(110, aGValue);
DMX.write(111, aBValue);
DMX.write(112, bRValue);
DMX.write(113, bGValue);
DMX.write(114, bBValue);
DMX.write(115, cRValue);
DMX.write(116, cGValue);
DMX.write(117, cBValue);
DMX.write(118, aRValue);
DMX.write(119, aGValue);
DMX.write(120, aBValue);
DMX.write(121, bRValue);
DMX.write(122, bGValue);
DMX.write(123, bBValue);
DMX.write(124, cRValue);
DMX.write(125, cGValue);
DMX.write(126, cBValue);
DMX.write(127, aRValue);
DMX.write(128, aGValue);
DMX.write(129, aBValue);
DMX.write(130, bRValue);
DMX.write(131, bGValue);
DMX.write(132, bBValue);
DMX.write(133, cRValue);
DMX.write(134, cGValue);
DMX.write(135, cBValue);
DMX.write(136, aRValue);
DMX.write(137, aGValue);
DMX.write(138, aBValue);
DMX.write(139, bRValue);
DMX.write(140, bGValue);
DMX.write(141, bBValue);
DMX.write(142, cRValue);
DMX.write(143, cGValue);
DMX.write(144, cBValue);
DMX.write(145, aRValue);
DMX.write(146, aGValue);
DMX.write(147, aBValue);
DMX.write(148, bRValue);
DMX.write(149, bGValue);
DMX.write(150, bBValue);
DMX.write(151, cRValue);
DMX.write(152, cGValue);
DMX.write(153, cBValue);
DMX.write(154, aRValue);
DMX.write(155, aGValue);
DMX.write(156, aBValue);
DMX.write(157, bRValue);
DMX.write(158, bGValue);
DMX.write(159, bBValue);
DMX.write(160, cRValue);
DMX.write(161, cGValue);
DMX.write(162, cBValue);
DMX.write(163, aRValue);
DMX.write(164, aGValue);
DMX.write(165, aBValue);
DMX.write(166, bRValue);
DMX.write(167, bGValue);
DMX.write(168, bBValue);
DMX.write(169, cRValue);
DMX.write(170, cGValue);
DMX.write(171, cBValue);
DMX.write(172, aRValue);
DMX.write(173, aGValue);
DMX.write(174, aBValue);
DMX.write(175, bRValue);
DMX.write(176, bGValue);
DMX.write(177, bBValue);
DMX.write(178, cRValue);
DMX.write(179, cGValue);
DMX.write(180, cBValue);

          
          DMX.endTransmission(); 
          
          break;
          
          case 1:
          
          DMX.beginTransmission();
          DMX.write(1, cRValue);
DMX.write(2, cGValue);
DMX.write(3, cBValue);
DMX.write(4, aRValue);
DMX.write(5, aGValue);
DMX.write(6, aBValue);
DMX.write(7, bRValue);
DMX.write(8, bGValue);
DMX.write(9, bBValue);
DMX.write(10, cRValue);
DMX.write(11, cGValue);
DMX.write(12, cBValue);
DMX.write(13, aRValue);
DMX.write(14, aGValue);
DMX.write(15, aBValue);
DMX.write(16, bRValue);
DMX.write(17, bGValue);
DMX.write(18, bBValue);
DMX.write(19, cRValue);
DMX.write(20, cGValue);
DMX.write(21, cBValue);
DMX.write(22, aRValue);
DMX.write(23, aGValue);
DMX.write(24, aBValue);
DMX.write(25, bRValue);
DMX.write(26, bGValue);
DMX.write(27, bBValue);
DMX.write(28, cRValue);
DMX.write(29, cGValue);
DMX.write(30, cBValue);
DMX.write(31, aRValue);
DMX.write(32, aGValue);
DMX.write(33, aBValue);
DMX.write(34, bRValue);
DMX.write(35, bGValue);
DMX.write(36, bBValue);
DMX.write(37, cRValue);
DMX.write(38, cGValue);
DMX.write(39, cBValue);
DMX.write(40, aRValue);
DMX.write(41, aGValue);
DMX.write(42, aBValue);
DMX.write(43, bRValue);
DMX.write(44, bGValue);
DMX.write(45, bBValue);
DMX.write(46, cRValue);
DMX.write(47, cGValue);
DMX.write(48, cBValue);
DMX.write(49, aRValue);
DMX.write(50, aGValue);
DMX.write(51, aBValue);
DMX.write(52, bRValue);
DMX.write(53, bGValue);
DMX.write(54, bBValue);
DMX.write(55, cRValue);
DMX.write(56, cGValue);
DMX.write(57, cBValue);
DMX.write(58, aRValue);
DMX.write(59, aGValue);
DMX.write(60, aBValue);
DMX.write(61, bRValue);
DMX.write(62, bGValue);
DMX.write(63, bBValue);
DMX.write(64, cRValue);
DMX.write(65, cGValue);
DMX.write(66, cBValue);
DMX.write(67, aRValue);
DMX.write(68, aGValue);
DMX.write(69, aBValue);
DMX.write(70, bRValue);
DMX.write(71, bGValue);
DMX.write(72, bBValue);
DMX.write(73, cRValue);
DMX.write(74, cGValue);
DMX.write(75, cBValue);
DMX.write(76, aRValue);
DMX.write(77, aGValue);
DMX.write(78, aBValue);
DMX.write(79, bRValue);
DMX.write(80, bGValue);
DMX.write(81, bBValue);
DMX.write(82, cRValue);
DMX.write(83, cGValue);
DMX.write(84, cBValue);
DMX.write(85, aRValue);
DMX.write(86, aGValue);
DMX.write(87, aBValue);
DMX.write(88, bRValue);
DMX.write(89, bGValue);
DMX.write(90, bBValue);
DMX.write(91, cRValue);
DMX.write(92, cGValue);
DMX.write(93, cBValue);
DMX.write(94, aRValue);
DMX.write(95, aGValue);
DMX.write(96, aBValue);
DMX.write(97, bRValue);
DMX.write(98, bGValue);
DMX.write(99, bBValue);
DMX.write(100, cRValue);
DMX.write(101, cGValue);
DMX.write(102, cBValue);
DMX.write(103, aRValue);
DMX.write(104, aGValue);
DMX.write(105, aBValue);
DMX.write(106, bRValue);
DMX.write(107, bGValue);
DMX.write(108, bBValue);
DMX.write(109, cRValue);
DMX.write(110, cGValue);
DMX.write(111, cBValue);
DMX.write(112, aRValue);
DMX.write(113, aGValue);
DMX.write(114, aBValue);
DMX.write(115, bRValue);
DMX.write(116, bGValue);
DMX.write(117, bBValue);
DMX.write(118, cRValue);
DMX.write(119, cGValue);
DMX.write(120, cBValue);
DMX.write(121, aRValue);
DMX.write(122, aGValue);
DMX.write(123, aBValue);
DMX.write(124, bRValue);
DMX.write(125, bGValue);
DMX.write(126, bBValue);
DMX.write(127, cRValue);
DMX.write(128, cGValue);
DMX.write(129, cBValue);
DMX.write(130, aRValue);
DMX.write(131, aGValue);
DMX.write(132, aBValue);
DMX.write(133, bRValue);
DMX.write(134, bGValue);
DMX.write(135, bBValue);
DMX.write(136, cRValue);
DMX.write(137, cGValue);
DMX.write(138, cBValue);
DMX.write(139, aRValue);
DMX.write(140, aGValue);
DMX.write(141, aBValue);
DMX.write(142, bRValue);
DMX.write(143, bGValue);
DMX.write(144, bBValue);
DMX.write(145, cRValue);
DMX.write(146, cGValue);
DMX.write(147, cBValue);
DMX.write(148, aRValue);
DMX.write(149, aGValue);
DMX.write(150, aBValue);
DMX.write(151, bRValue);
DMX.write(152, bGValue);
DMX.write(153, bBValue);
DMX.write(154, cRValue);
DMX.write(155, cGValue);
DMX.write(156, cBValue);
DMX.write(157, aRValue);
DMX.write(158, aGValue);
DMX.write(159, aBValue);
DMX.write(160, bRValue);
DMX.write(161, bGValue);
DMX.write(162, bBValue);
DMX.write(163, cRValue);
DMX.write(164, cGValue);
DMX.write(165, cBValue);
DMX.write(166, aRValue);
DMX.write(167, aGValue);
DMX.write(168, aBValue);
DMX.write(169, bRValue);
DMX.write(170, bGValue);
DMX.write(171, bBValue);
DMX.write(172, cRValue);
DMX.write(173, cGValue);
DMX.write(174, cBValue);
DMX.write(175, aRValue);
DMX.write(176, aGValue);
DMX.write(177, aBValue);
DMX.write(178, bRValue);
DMX.write(179, bGValue);
DMX.write(180, bBValue);

          DMX.endTransmission(); 
          
          break;
    
          case 2:
          
          DMX.beginTransmission();
          
DMX.write(1, bRValue);
DMX.write(2, bGValue);
DMX.write(3, bBValue);
DMX.write(4, cRValue);
DMX.write(5, cGValue);
DMX.write(6, cBValue);
DMX.write(7, aRValue);
DMX.write(8, aGValue);
DMX.write(9, aBValue);
DMX.write(10, bRValue);
DMX.write(11, bGValue);
DMX.write(12, bBValue);
DMX.write(13, cRValue);
DMX.write(14, cGValue);
DMX.write(15, cBValue);
DMX.write(16, aRValue);
DMX.write(17, aGValue);
DMX.write(18, aBValue);
DMX.write(19, bRValue);
DMX.write(20, bGValue);
DMX.write(21, bBValue);
DMX.write(22, cRValue);
DMX.write(23, cGValue);
DMX.write(24, cBValue);
DMX.write(25, aRValue);
DMX.write(26, aGValue);
DMX.write(27, aBValue);
DMX.write(28, bRValue);
DMX.write(29, bGValue);
DMX.write(30, bBValue);
DMX.write(31, cRValue);
DMX.write(32, cGValue);
DMX.write(33, cBValue);
DMX.write(34, aRValue);
DMX.write(35, aGValue);
DMX.write(36, aBValue);
DMX.write(37, bRValue);
DMX.write(38, bGValue);
DMX.write(39, bBValue);
DMX.write(40, cRValue);
DMX.write(41, cGValue);
DMX.write(42, cBValue);
DMX.write(43, aRValue);
DMX.write(44, aGValue);
DMX.write(45, aBValue);
DMX.write(46, bRValue);
DMX.write(47, bGValue);
DMX.write(48, bBValue);
DMX.write(49, cRValue);
DMX.write(50, cGValue);
DMX.write(51, cBValue);
DMX.write(52, aRValue);
DMX.write(53, aGValue);
DMX.write(54, aBValue);
DMX.write(55, bRValue);
DMX.write(56, bGValue);
DMX.write(57, bBValue);
DMX.write(58, cRValue);
DMX.write(59, cGValue);
DMX.write(60, cBValue);
DMX.write(61, aRValue);
DMX.write(62, aGValue);
DMX.write(63, aBValue);
DMX.write(64, bRValue);
DMX.write(65, bGValue);
DMX.write(66, bBValue);
DMX.write(67, cRValue);
DMX.write(68, cGValue);
DMX.write(69, cBValue);
DMX.write(70, aRValue);
DMX.write(71, aGValue);
DMX.write(72, aBValue);
DMX.write(73, bRValue);
DMX.write(74, bGValue);
DMX.write(75, bBValue);
DMX.write(76, cRValue);
DMX.write(77, cGValue);
DMX.write(78, cBValue);
DMX.write(79, aRValue);
DMX.write(80, aGValue);
DMX.write(81, aBValue);
DMX.write(82, bRValue);
DMX.write(83, bGValue);
DMX.write(84, bBValue);
DMX.write(85, cRValue);
DMX.write(86, cGValue);
DMX.write(87, cBValue);
DMX.write(88, aRValue);
DMX.write(89, aGValue);
DMX.write(90, aBValue);
DMX.write(91, bRValue);
DMX.write(92, bGValue);
DMX.write(93, bBValue);
DMX.write(94, cRValue);
DMX.write(95, cGValue);
DMX.write(96, cBValue);
DMX.write(97, aRValue);
DMX.write(98, aGValue);
DMX.write(99, aBValue);
DMX.write(100, bRValue);
DMX.write(101, bGValue);
DMX.write(102, bBValue);
DMX.write(103, cRValue);
DMX.write(104, cGValue);
DMX.write(105, cBValue);
DMX.write(106, aRValue);
DMX.write(107, aGValue);
DMX.write(108, aBValue);
DMX.write(109, bRValue);
DMX.write(110, bGValue);
DMX.write(111, bBValue);
DMX.write(112, cRValue);
DMX.write(113, cGValue);
DMX.write(114, cBValue);
DMX.write(115, aRValue);
DMX.write(116, aGValue);
DMX.write(117, aBValue);
DMX.write(118, bRValue);
DMX.write(119, bGValue);
DMX.write(120, bBValue);
DMX.write(121, cRValue);
DMX.write(122, cGValue);
DMX.write(123, cBValue);
DMX.write(124, aRValue);
DMX.write(125, aGValue);
DMX.write(126, aBValue);
DMX.write(127, bRValue);
DMX.write(128, bGValue);
DMX.write(129, bBValue);
DMX.write(130, cRValue);
DMX.write(131, cGValue);
DMX.write(132, cBValue);
DMX.write(133, aRValue);
DMX.write(134, aGValue);
DMX.write(135, aBValue);
DMX.write(136, bRValue);
DMX.write(137, bGValue);
DMX.write(138, bBValue);
DMX.write(139, cRValue);
DMX.write(140, cGValue);
DMX.write(141, cBValue);
DMX.write(142, aRValue);
DMX.write(143, aGValue);
DMX.write(144, aBValue);
DMX.write(145, bRValue);
DMX.write(146, bGValue);
DMX.write(147, bBValue);
DMX.write(148, cRValue);
DMX.write(149, cGValue);
DMX.write(150, cBValue);
DMX.write(151, aRValue);
DMX.write(152, aGValue);
DMX.write(153, aBValue);
DMX.write(154, bRValue);
DMX.write(155, bGValue);
DMX.write(156, bBValue);
DMX.write(157, cRValue);
DMX.write(158, cGValue);
DMX.write(159, cBValue);
DMX.write(160, aRValue);
DMX.write(161, aGValue);
DMX.write(162, aBValue);
DMX.write(163, bRValue);
DMX.write(164, bGValue);
DMX.write(165, bBValue);
DMX.write(166, cRValue);
DMX.write(167, cGValue);
DMX.write(168, cBValue);
DMX.write(169, aRValue);
DMX.write(170, aGValue);
DMX.write(171, aBValue);
DMX.write(172, bRValue);
DMX.write(173, bGValue);
DMX.write(174, bBValue);
DMX.write(175, cRValue);
DMX.write(176, cGValue);
DMX.write(177, cBValue);
DMX.write(178, aRValue);
DMX.write(179, aGValue);
DMX.write(180, aBValue);

          DMX.endTransmission(); 
          
          break;
  }
        
        step++;
        if (step > 2) {
          step = 0;
        }
      }
      
    } else {
          
          DMX.beginTransmission();
          DMX.write(1, aRValue);
DMX.write(2, aGValue);
DMX.write(3, aBValue);
DMX.write(4, bRValue);
DMX.write(5, bGValue);
DMX.write(6, bBValue);
DMX.write(7, cRValue);
DMX.write(8, cGValue);
DMX.write(9, cBValue);
DMX.write(10, aRValue);
DMX.write(11, aGValue);
DMX.write(12, aBValue);
DMX.write(13, bRValue);
DMX.write(14, bGValue);
DMX.write(15, bBValue);
DMX.write(16, cRValue);
DMX.write(17, cGValue);
DMX.write(18, cBValue);
DMX.write(19, aRValue);
DMX.write(20, aGValue);
DMX.write(21, aBValue);
DMX.write(22, bRValue);
DMX.write(23, bGValue);
DMX.write(24, bBValue);
DMX.write(25, cRValue);
DMX.write(26, cGValue);
DMX.write(27, cBValue);
DMX.write(28, aRValue);
DMX.write(29, aGValue);
DMX.write(30, aBValue);
DMX.write(31, bRValue);
DMX.write(32, bGValue);
DMX.write(33, bBValue);
DMX.write(34, cRValue);
DMX.write(35, cGValue);
DMX.write(36, cBValue);
DMX.write(37, aRValue);
DMX.write(38, aGValue);
DMX.write(39, aBValue);
DMX.write(40, bRValue);
DMX.write(41, bGValue);
DMX.write(42, bBValue);
DMX.write(43, cRValue);
DMX.write(44, cGValue);
DMX.write(45, cBValue);
DMX.write(46, aRValue);
DMX.write(47, aGValue);
DMX.write(48, aBValue);
DMX.write(49, bRValue);
DMX.write(50, bGValue);
DMX.write(51, bBValue);
DMX.write(52, cRValue);
DMX.write(53, cGValue);
DMX.write(54, cBValue);
DMX.write(55, aRValue);
DMX.write(56, aGValue);
DMX.write(57, aBValue);
DMX.write(58, bRValue);
DMX.write(59, bGValue);
DMX.write(60, bBValue);
DMX.write(61, cRValue);
DMX.write(62, cGValue);
DMX.write(63, cBValue);
DMX.write(64, aRValue);
DMX.write(65, aGValue);
DMX.write(66, aBValue);
DMX.write(67, bRValue);
DMX.write(68, bGValue);
DMX.write(69, bBValue);
DMX.write(70, cRValue);
DMX.write(71, cGValue);
DMX.write(72, cBValue);
DMX.write(73, aRValue);
DMX.write(74, aGValue);
DMX.write(75, aBValue);
DMX.write(76, bRValue);
DMX.write(77, bGValue);
DMX.write(78, bBValue);
DMX.write(79, cRValue);
DMX.write(80, cGValue);
DMX.write(81, cBValue);
DMX.write(82, aRValue);
DMX.write(83, aGValue);
DMX.write(84, aBValue);
DMX.write(85, bRValue);
DMX.write(86, bGValue);
DMX.write(87, bBValue);
DMX.write(88, cRValue);
DMX.write(89, cGValue);
DMX.write(90, cBValue);
DMX.write(91, aRValue);
DMX.write(92, aGValue);
DMX.write(93, aBValue);
DMX.write(94, bRValue);
DMX.write(95, bGValue);
DMX.write(96, bBValue);
DMX.write(97, cRValue);
DMX.write(98, cGValue);
DMX.write(99, cBValue);
DMX.write(100, aRValue);
DMX.write(101, aGValue);
DMX.write(102, aBValue);
DMX.write(103, bRValue);
DMX.write(104, bGValue);
DMX.write(105, bBValue);
DMX.write(106, cRValue);
DMX.write(107, cGValue);
DMX.write(108, cBValue);
DMX.write(109, aRValue);
DMX.write(110, aGValue);
DMX.write(111, aBValue);
DMX.write(112, bRValue);
DMX.write(113, bGValue);
DMX.write(114, bBValue);
DMX.write(115, cRValue);
DMX.write(116, cGValue);
DMX.write(117, cBValue);
DMX.write(118, aRValue);
DMX.write(119, aGValue);
DMX.write(120, aBValue);
DMX.write(121, bRValue);
DMX.write(122, bGValue);
DMX.write(123, bBValue);
DMX.write(124, cRValue);
DMX.write(125, cGValue);
DMX.write(126, cBValue);
DMX.write(127, aRValue);
DMX.write(128, aGValue);
DMX.write(129, aBValue);
DMX.write(130, bRValue);
DMX.write(131, bGValue);
DMX.write(132, bBValue);
DMX.write(133, cRValue);
DMX.write(134, cGValue);
DMX.write(135, cBValue);
DMX.write(136, aRValue);
DMX.write(137, aGValue);
DMX.write(138, aBValue);
DMX.write(139, bRValue);
DMX.write(140, bGValue);
DMX.write(141, bBValue);
DMX.write(142, cRValue);
DMX.write(143, cGValue);
DMX.write(144, cBValue);
DMX.write(145, aRValue);
DMX.write(146, aGValue);
DMX.write(147, aBValue);
DMX.write(148, bRValue);
DMX.write(149, bGValue);
DMX.write(150, bBValue);
DMX.write(151, cRValue);
DMX.write(152, cGValue);
DMX.write(153, cBValue);
DMX.write(154, aRValue);
DMX.write(155, aGValue);
DMX.write(156, aBValue);
DMX.write(157, bRValue);
DMX.write(158, bGValue);
DMX.write(159, bBValue);
DMX.write(160, cRValue);
DMX.write(161, cGValue);
DMX.write(162, cBValue);
DMX.write(163, aRValue);
DMX.write(164, aGValue);
DMX.write(165, aBValue);
DMX.write(166, bRValue);
DMX.write(167, bGValue);
DMX.write(168, bBValue);
DMX.write(169, cRValue);
DMX.write(170, cGValue);
DMX.write(171, cBValue);
DMX.write(172, aRValue);
DMX.write(173, aGValue);
DMX.write(174, aBValue);
DMX.write(175, bRValue);
DMX.write(176, bGValue);
DMX.write(177, bBValue);
DMX.write(178, cRValue);
DMX.write(179, cGValue);
DMX.write(180, cBValue);

          DMX.endTransmission(); 
          
         }
      
  } 
  
  else {
    
    power = false; 

    digitalWrite(statusC, LOW);
          
          DMX.beginTransmission();
          DMX.write(1, 0);
DMX.write(2, 0);
DMX.write(3, 0);
DMX.write(4, 0);
DMX.write(5, 0);
DMX.write(6, 0);
DMX.write(7, 0);
DMX.write(8, 0);
DMX.write(9, 0);
DMX.write(10, 0);
DMX.write(11, 0);
DMX.write(12, 0);
DMX.write(13, 0);
DMX.write(14, 0);
DMX.write(15, 0);
DMX.write(16, 0);
DMX.write(17, 0);
DMX.write(18, 0);
DMX.write(19, 0);
DMX.write(20, 0);
DMX.write(21, 0);
DMX.write(22, 0);
DMX.write(23, 0);
DMX.write(24, 0);
DMX.write(25, 0);
DMX.write(26, 0);
DMX.write(27, 0);
DMX.write(28, 0);
DMX.write(29, 0);
DMX.write(30, 0);
DMX.write(31, 0);
DMX.write(32, 0);
DMX.write(33, 0);
DMX.write(34, 0);
DMX.write(35, 0);
DMX.write(36, 0);
DMX.write(37, 0);
DMX.write(38, 0);
DMX.write(39, 0);
DMX.write(40, 0);
DMX.write(41, 0);
DMX.write(42, 0);
DMX.write(43, 0);
DMX.write(44, 0);
DMX.write(45, 0);
DMX.write(46, 0);
DMX.write(47, 0);
DMX.write(48, 0);
DMX.write(49, 0);
DMX.write(50, 0);
DMX.write(51, 0);
DMX.write(52, 0);
DMX.write(53, 0);
DMX.write(54, 0);
DMX.write(55, 0);
DMX.write(56, 0);
DMX.write(57, 0);
DMX.write(58, 0);
DMX.write(59, 0);
DMX.write(60, 0);
DMX.write(61, 0);
DMX.write(62, 0);
DMX.write(63, 0);
DMX.write(64, 0);
DMX.write(65, 0);
DMX.write(66, 0);
DMX.write(67, 0);
DMX.write(68, 0);
DMX.write(69, 0);
DMX.write(70, 0);
DMX.write(71, 0);
DMX.write(72, 0);
DMX.write(73, 0);
DMX.write(74, 0);
DMX.write(75, 0);
DMX.write(76, 0);
DMX.write(77, 0);
DMX.write(78, 0);
DMX.write(79, 0);
DMX.write(80, 0);
DMX.write(81, 0);
DMX.write(82, 0);
DMX.write(83, 0);
DMX.write(84, 0);
DMX.write(85, 0);
DMX.write(86, 0);
DMX.write(87, 0);
DMX.write(88, 0);
DMX.write(89, 0);
DMX.write(90, 0);
DMX.write(91, 0);
DMX.write(92, 0);
DMX.write(93, 0);
DMX.write(94, 0);
DMX.write(95, 0);
DMX.write(96, 0);
DMX.write(97, 0);
DMX.write(98, 0);
DMX.write(99, 0);
DMX.write(100, 0);
DMX.write(101, 0);
DMX.write(102, 0);
DMX.write(103, 0);
DMX.write(104, 0);
DMX.write(105, 0);
DMX.write(106, 0);
DMX.write(107, 0);
DMX.write(108, 0);
DMX.write(109, 0);
DMX.write(110, 0);
DMX.write(111, 0);
DMX.write(112, 0);
DMX.write(113, 0);
DMX.write(114, 0);
DMX.write(115, 0);
DMX.write(116, 0);
DMX.write(117, 0);
DMX.write(118, 0);
DMX.write(119, 0);
DMX.write(120, 0);
DMX.write(121, 0);
DMX.write(122, 0);
DMX.write(123, 0);
DMX.write(124, 0);
DMX.write(125, 0);
DMX.write(126, 0);
DMX.write(127, 0);
DMX.write(128, 0);
DMX.write(129, 0);
DMX.write(130, 0);
DMX.write(131, 0);
DMX.write(132, 0);
DMX.write(133, 0);
DMX.write(134, 0);
DMX.write(135, 0);
DMX.write(136, 0);
DMX.write(137, 0);
DMX.write(138, 0);
DMX.write(139, 0);
DMX.write(140, 0);
DMX.write(141, 0);
DMX.write(142, 0);
DMX.write(143, 0);
DMX.write(144, 0);
DMX.write(145, 0);
DMX.write(146, 0);
DMX.write(147, 0);
DMX.write(148, 0);
DMX.write(149, 0);
DMX.write(150, 0);
DMX.write(151, 0);
DMX.write(152, 0);
DMX.write(153, 0);
DMX.write(154, 0);
DMX.write(155, 0);
DMX.write(156, 0);
DMX.write(157, 0);
DMX.write(158, 0);
DMX.write(159, 0);
DMX.write(160, 0);
DMX.write(161, 0);
DMX.write(162, 0);
DMX.write(163, 0);
DMX.write(164, 0);
DMX.write(165, 0);
DMX.write(166, 0);
DMX.write(167, 0);
DMX.write(168, 0);
DMX.write(169, 0);
DMX.write(170, 0);
DMX.write(171, 0);
DMX.write(172, 0);
DMX.write(173, 0);
DMX.write(174, 0);
DMX.write(175, 0);
DMX.write(176, 0);
DMX.write(177, 0);
DMX.write(178, 0);
DMX.write(179, 0);
DMX.write(180, 0);

          DMX.endTransmission(); 
          
  }
  
}



void checkHeartbeat() {
  if (hbSched.isActive()) {
    heartbeat = true;
    digitalWrite(hbPin, HIGH);
    digitalWrite(statusA, HIGH);
  } else {
    heartbeat = false;
    digitalWrite(hbPin, LOW);
    digitalWrite(statusA, LOW);
  }
}

void toggleStatusB() {
  if (millis() - lastToggleTime >= 500) {
    lastToggleTime = millis();
    statusBState = !statusBState;
    digitalWrite(statusB, statusBState);
  }
}

  void luxLoop() {
  if (millis() - lastLuxTime >= 60000) {
    lastLuxTime = millis();
    lux = analogRead(luxPin);
  }
}


/*
  Since Power is READ_WRITE variable, onPowerChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onPowerChange()  {
  // Add your code here to act upon Power change
}

/*
  Since AColour is READ_WRITE variable, onAColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onAColourChange()  {
  // Add your code here to act upon AColour change
}

/*
  Since BColour is READ_WRITE variable, onBColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onBColourChange()  {
  // Add your code here to act upon BColour change
}

/*
  Since CColour is READ_WRITE variable, onCColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onCColourChange()  {
  // Add your code here to act upon CColour change
}

/*
  Since FxSpeed is READ_WRITE variable, onFxSpeedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onFxSpeedChange()  {
  // Add your code here to act upon FxSpeed change
}

/*
  Since HbSched is READ_WRITE variable, onHbSchedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHbSchedChange()  {
  // Add your code here to act upon HbSched change
}

/*
  Since OnTime is READ_WRITE variable, onOnTimeChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onOnTimeChange()  {
  // Add your code here to act upon OnTime change
}

/*
  Since Effect is READ_WRITE variable, onEffectChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onEffectChange()  {
  // Add your code here to act upon Effect change
}


/*
  Since Heartbeat is READ_WRITE variable, onHeartbeatChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHeartbeatChange()  {
  // Add your code here to act upon Heartbeat change
}

/*
  Since Temp is READ_WRITE variable, onTempChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onTempChange()  {
  // Add your code here to act upon Temp change
}

/*
  Since Humid is READ_WRITE variable, onHumidChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHumidChange()  {
  // Add your code here to act upon Humid change
}











/*
  Since Lux is READ_WRITE variable, onLuxChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLuxChange()  {
  // Add your code here to act upon Lux change
}
/*
  Since Current is READ_WRITE variable, onCurrentChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onCurrentChange()  {
  // Add your code here to act upon Current change
}

Can anyone see any differences that might cause this error?

Thank you all so much,

M

can you try to identify if the code starts running and then where it might be getting hung up using LEDs

@apf1979, @gcjr, @camsysca, @madmark2150 @pennam et al.

Some time has passed since my last post but I am still getting this issue coming around and haunting me... Any advice from anyone would be greatly appreciated, am almost at the point of total bafflement.

I have a little more information but will recap...

Code runs correctly when connected to the USB of my PC, but not when powered by anything else, USB psu via the same cable or powering directly via the VIN or 5V pins it does not work correctly.

Issue is now that when I first boot the MKR it grabs the variables as they are in the cloud when booting, but never again, I can change the value of 'fairyColour' for example from the dashboard but the MKR does not update the values of these variables again once booted. The MKR is however able to update the cloud with the variables it is editing such as 'heartbeat' I see this change every 30 seconds at the dashboard as it should.

Conversely, if the MKR is connected to the USB port on my laptop, the updates are bidirectional and work perfectly and quickly.

Here is my code, a lot of it has to do with controlling DMX but I was criticised in the past for not posting it all, so here you go.

Thank you all so much.

M

/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/fbe406c6-9b6c-44e5-9292-063c839d8025

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  int fairyColour;
  int stripColour;
  CloudSchedule hbSched;
  CloudSchedule onTime;
  bool heartbeat;
  bool power;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

// ArduinoRS485 - Version: Latest
#include <ArduinoRS485.h>

// ArduinoDMX - Version: Latest
#include <ArduinoDMX.h>

const int hbPin = 8;
const int statusA = 2;
const int statusB = 3;
const int statusC = 4;
const int testPin = 6;

const int universeSize = 20;
unsigned long lastToggleTime = 0;
bool statusBState = false;
const unsigned long interval = 5 * 60 * 1000;  // Delay interval in milliseconds
unsigned long previousMillis = 0;
int currentState = 0;

int dmxA = 255;
int dmxB = 255;
int dmxC = 108;
int dmxD = 108;



void setup() {
  // Initialize serial and wait for port to open:
  //Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  //delay(5000);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  pinMode(hbPin, OUTPUT);
  pinMode(statusA, OUTPUT);
  pinMode(statusB, OUTPUT);
  pinMode(statusC, OUTPUT);
  pinMode(testPin, OUTPUT);

  DMX.begin(universeSize); // initialize the DMX library with the universe size


  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();

  Serial.println(fairyColour);
  Serial.println(dmxA);
  Serial.println(dmxB);
  Serial.println(dmxD);

  switch (fairyColour) {

    case 1:  //Static Red

      dmxA = 255;
      dmxB = 255;
      dmxC = 255;
      dmxD = 108;

      break;

    case 2:  //Static Green

      dmxA = 255;
      dmxB = 255;
      dmxC = 255;
      dmxD = 0;

      break;

    case 3:  //Static Yellow

      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 255;

      break;

    case 4:  //Static Blue

      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 108;

      break;

    case 5:  //Static Magenta

      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 0;

      break;

    case 6:  //Static Cyan

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 255;

      break;

    case 7:  //Static White

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 108;

      break;

    case 8:  //Static Multicoloured

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 0;

      break;

    case 9:  //2 second fade up and down in RED

      dmxA = 0;
      dmxB = 255;
      dmxC = 0;
      dmxD = 108;

      break;

    case 10:  //2 second fade up and down in GREEN

      dmxA = 0;
      dmxB = 255;
      dmxC = 0;
      dmxD = 0;

      break;

    case 11:  //2 second fade up and down in YELLOW

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 255;

      break;

    case 12:  //2 second fade up and down in BLUE

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 108;

      break;

    case 13:  //2 second fade up and down in MAGENTA

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 0;

      break;

    case 14:  //2 second fade up and down in CYAN

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 255;

      break;

    case 15:  //2 second fade up and down in WHITE

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 16:  //2 second fade up and down in MULTICOLOUR

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 17:  //Fast white twinkle in RED

      dmxA = 108;
      dmxB = 108;
      dmxC = 255;
      dmxD = 108;

      break;

    case 18:  //Fast white twinkle in GREEN

      dmxA = 108;
      dmxB = 108;
      dmxC = 255;
      dmxD = 0;

      break;

    case 19:  //Fast white twinkle in YELLOW

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 255;

      break;

    case 20:  //Fast white twinkle in BLUE

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 21:  //Fast white twinkle in MAGENTA

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 22:  //Fast white twinkle in CYAN

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 23:  //Fast white twinkle in WHITE

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 24:  //Fast white twinkle in MULTICOLOUR

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;

    case 25:  //All off with fast twinkle in RED

      dmxA = 0;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 26:  //All off with fast twinkle in GREEN

      dmxA = 0;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 27:  //All off with fast twinkle in YELLOW

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 28:  //All off with fast twinkle in BLUE

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 29:  //All off with fast twinkle in MAGENTA

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;

    case 30:  //All off with fast twinkle in CYAN

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;


      break;

    case 31:  //All off with fast twinkle in WHITE

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 32:  //All off with fast twinkle in MULTICOLOUR

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 33:  //Slow white twinkle on RED

      dmxA = 255;
      dmxB = 0;
      dmxC = 0;
      dmxD = 108;

      break;

    case 34:  //Slow white twinkle on GREEN

      dmxA = 255;
      dmxB = 0;
      dmxC = 0;
      dmxD = 0;

      break;

    case 35:  //Slow white twinkle on YELLOW

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;

      break;

    case 36:  //Slow white twinkle on BLUE

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 37:  //Slow white twinkle on MAGENTA

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 38:  //Slow white twinkle on CYAN

      dmxA = 108;
      dmxB = 0;
      dmxC = 108;
      dmxD = 255;

      break;

    case 39:  //Slow white twinkle on WHITE

      dmxA = 108;
      dmxB = 0;
      dmxC = 108;
      dmxD = 108;

      break;

    case 40:  //Slow white twinkle on MULTICOLOUR

      dmxA = 0;
      dmxB = 0;
      dmxC = 108;
      dmxD = 0;

      break;

    case 41:  //Twinkling slowly to off in RED

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 255;

      break;

    case 42:  //Twinkling slowly to off in GREEN

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 108;

      break;

    case 43:  //Twinkling slowly to off in YELLOW

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 0;

      break;

    case 44:  //Twinkling slowly to off in BLUE

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;

      break;

    case 45:  //Twinkling slowly to off in MAGENTA

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 46:  //Twinkling slowly to off in CYAN

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 47:  //Twinkling slowly to off in WHITE

      dmxA = 0;
      dmxB = 0;
      dmxC = 108;
      dmxD = 255;

      break;

    case 48:  //Twinkling slowly to off in MULTICOLOUR

      dmxA = 0;
      dmxB = 0;
      dmxC = 0;
      dmxD = 255;

      break;

    case 49:  //Off with slow twinkle in RED

      dmxA = 108;
      dmxB = 255;
      dmxC = 255;
      dmxD = 108;

      break;

    case 50:  //Off with slow twinkle in GREEN

      dmxA = 108;
      dmxB = 255;
      dmxC = 255;
      dmxD = 0;

      break;

    case 51:  //Off with slow twinkle in YELLOW

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 255;

      break;

    case 52:  //Off with slow twinkle in BLUE

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 108;

      break;

    case 53:  //Off with slow twinkle in MAGENTA

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 0;

      break;

    case 54:  //Off with slow twinkle in CYAN

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 55:  //Off with slow twinkle in WHITE

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 56:  //Off with slow twinkle in MULTICOLOUR

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;
  } //close








  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) { // Code to refresh DMX for Subs
    previousMillis = currentMillis;
    DMX.beginTransmission();

    DMX.write(1, 0);
    DMX.write(2, 0);
    DMX.write(3, 0);
    DMX.write(4, 0);
    DMX.write(5, 0);
    DMX.write(6, 0);
    DMX.write(7, 0);
    DMX.write(8, 0);
    DMX.write(9, 0);
    DMX.write(10, 0);
    DMX.write(11, 0);
    DMX.write(12, 0);
    DMX.write(13, 0);
    DMX.write(14, 0);
    DMX.write(15, 0);
    DMX.write(16, 0);
    DMX.write(17, 0);
    DMX.write(18, 0);
    DMX.write(19, 0);
    DMX.write(20, 0);

    DMX.endTransmission();

  }


  if (onTime.isActive()) {

    power = true;

    digitalWrite(statusC, HIGH);



    DMX.beginTransmission();

    DMX.write(1, dmxA);
    DMX.write(2, dmxB);
    DMX.write(3, dmxC);
    DMX.write(4, dmxD);
    DMX.write(5, dmxA);
    DMX.write(6, dmxB);
    DMX.write(7, dmxC);
    DMX.write(8, dmxD);
    DMX.write(9, dmxA);
    DMX.write(10, dmxB);
    DMX.write(11, dmxC);
    DMX.write(12, dmxD);
    DMX.write(13, dmxA);
    DMX.write(14, dmxB);
    DMX.write(15, dmxC);
    DMX.write(16, dmxD);
    DMX.write(17, dmxA);
    DMX.write(18, dmxB);
    DMX.write(19, dmxC);
    DMX.write(20, dmxD);

    DMX.endTransmission();

  }

  else {  //Set DMX output to OFF


    DMX.write(1, 255);
    DMX.write(2, 255);
    DMX.write(3, 255);
    DMX.write(4, 255);
    DMX.write(5, 255);
    DMX.write(6, 255);
    DMX.write(7, 255);
    DMX.write(8, 255);
    DMX.write(9, 255);
    DMX.write(10, 255);
    DMX.write(11, 255);
    DMX.write(12, 255);
    DMX.write(13, 255);
    DMX.write(14, 255);
    DMX.write(15, 255);
    DMX.write(16, 255);
    DMX.write(17, 255);
    DMX.write(18, 255);
    DMX.write(19, 255);
    DMX.write(20, 255);


    power = false;

    digitalWrite(statusC, LOW);


  }  // Close else



  if (hbSched.isActive()) {
    heartbeat = true;
    digitalWrite(hbPin, HIGH);
    //digitalWrite(statusA, HIGH);
  } else {
    heartbeat = false;
    digitalWrite(hbPin, LOW);
    //digitalWrite(statusA, LOW);
  }



  if (millis() - lastToggleTime >= 500) {
    lastToggleTime = millis();
    statusBState = !statusBState;
    digitalWrite(statusB, statusBState);
  }

if (fairyColour == 1){
  
  digitalWrite(statusA, HIGH);
  digitalWrite(testPin, HIGH);
}

else {
  
  digitalWrite(statusA, LOW);
  digitalWrite(testPin, LOW);
}
}


/*
  Since Power is READ_WRITE variable, onPowerChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onPowerChange()  {
  // Add your code here to act upon Power change
}

/*
  Since FairyColour is READ_WRITE variable, onFairyColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onFairyColourChange()  {
  // Add your code here to act upon FairyColour change
}

/*
  Since OnTime is READ_WRITE variable, onOnTimeChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onOnTimeChange()  {
  // Add your code here to act upon OnTime change
}

/*
  Since HbSched is READ_WRITE variable, onHbSchedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHbSchedChange()  {
  // Add your code here to act upon HbSched change
}

/*
  Since Heartbeat is READ_WRITE variable, onHeartbeatChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHeartbeatChange()  {
  // Add your code here to act upon Heartbeat change
}

/*
  Since StripColour is READ_WRITE variable, onStripColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onStripColourChange()  {
  // Add your code here to act upon StripColour change
}



I took your loop() code apart, extracted the big switch, and the three dmx blox, to arrive at the loop code below. Along the way, I noted that the block of dmx settings to '255' dont have a begin and end transmission, is that correct?
Here's just the loop, boiled down to it's logic. Below it are the two functions I created to extract the body. More encapsulation could be done, but at least the core logic is more visible now. It compiles, but of course I cannot do any testing.
Perhaps, this will allow you to see if something is miscoded:

void loop() {
  ArduinoCloud.update();

  Serial.println(fairyColour);
  Serial.println(dmxA);
  Serial.println(dmxB);
  Serial.println(dmxD);
  setdmx(fairyColour);
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) { // Code to refresh DMX for Subs
    previousMillis = currentMillis;
    dmxw(1);  //set dmx to zero
  }
  if (onTime.isActive()) {
    power = true;
    digitalWrite(statusC, HIGH);
    dmxw(2);  //set dmx to values
  }
  else {  //Set DMX output to OFF
    dmxw(3);  //set dmx to 255
    power = false;
    digitalWrite(statusC, LOW);
  }  // Close else
  if (hbSched.isActive()) {
    heartbeat = true;
    digitalWrite(hbPin, HIGH);
    //digitalWrite(statusA, HIGH);
  } else {
    heartbeat = false;
    digitalWrite(hbPin, LOW);
    //digitalWrite(statusA, LOW);
  }
  if (millis() - lastToggleTime >= 500) {
    lastToggleTime = millis();
    statusBState = !statusBState;
    digitalWrite(statusB, statusBState);
  }
  if (fairyColour == 1) {
    digitalWrite(statusA, HIGH);
    digitalWrite(testPin, HIGH);
  }
  else {
    digitalWrite(statusA, LOW);
    digitalWrite(testPin, LOW);
  }
}
void dmxw(int v) {
  switch (v) {
    case 1:
      DMX.beginTransmission();
      DMX.write(1, 0);
      DMX.write(2, 0);
      DMX.write(3, 0);
      DMX.write(4, 0);
      DMX.write(5, 0);
      DMX.write(6, 0);
      DMX.write(7, 0);
      DMX.write(8, 0);
      DMX.write(9, 0);
      DMX.write(10, 0);
      DMX.write(11, 0);
      DMX.write(12, 0);
      DMX.write(13, 0);
      DMX.write(14, 0);
      DMX.write(15, 0);
      DMX.write(16, 0);
      DMX.write(17, 0);
      DMX.write(18, 0);
      DMX.write(19, 0);
      DMX.write(20, 0);
      DMX.endTransmission();
      break;
    case 2:
      DMX.beginTransmission();
      DMX.write(1, dmxA);
      DMX.write(2, dmxB);
      DMX.write(3, dmxC);
      DMX.write(4, dmxD);
      DMX.write(5, dmxA);
      DMX.write(6, dmxB);
      DMX.write(7, dmxC);
      DMX.write(8, dmxD);
      DMX.write(9, dmxA);
      DMX.write(10, dmxB);
      DMX.write(11, dmxC);
      DMX.write(12, dmxD);
      DMX.write(13, dmxA);
      DMX.write(14, dmxB);
      DMX.write(15, dmxC);
      DMX.write(16, dmxD);
      DMX.write(17, dmxA);
      DMX.write(18, dmxB);
      DMX.write(19, dmxC);
      DMX.write(20, dmxD);

      DMX.endTransmission();
      break;
    case 3:
    //NO BEGIN TX??
      DMX.write(1, 255);
      DMX.write(2, 255);
      DMX.write(3, 255);
      DMX.write(4, 255);
      DMX.write(5, 255);
      DMX.write(6, 255);
      DMX.write(7, 255);
      DMX.write(8, 255);
      DMX.write(9, 255);
      DMX.write(10, 255);
      DMX.write(11, 255);
      DMX.write(12, 255);
      DMX.write(13, 255);
      DMX.write(14, 255);
      DMX.write(15, 255);
      DMX.write(16, 255);
      DMX.write(17, 255);
      DMX.write(18, 255);
      DMX.write(19, 255);
      DMX.write(20, 255);
    //NO END TX??
      break;
  }
}
void   setdmx(fairyColour) {
  switch (fairyColour) {
    case 1:  //Static Red
      dmxA = 255;
      dmxB = 255;
      dmxC = 255;
      dmxD = 108;
      break;
    case 2:  //Static Green
      dmxA = 255;
      dmxB = 255;
      dmxC = 255;
      dmxD = 0;
      break;
    case 3:  //Static Yellow
      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 255;
      break;
    case 4:  //Static Blue

      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 108;

      break;

    case 5:  //Static Magenta

      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 0;

      break;

    case 6:  //Static Cyan

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 255;

      break;

    case 7:  //Static White

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 108;

      break;

    case 8:  //Static Multicoloured

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 0;

      break;

    case 9:  //2 second fade up and down in RED

      dmxA = 0;
      dmxB = 255;
      dmxC = 0;
      dmxD = 108;

      break;

    case 10:  //2 second fade up and down in GREEN

      dmxA = 0;
      dmxB = 255;
      dmxC = 0;
      dmxD = 0;

      break;

    case 11:  //2 second fade up and down in YELLOW

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 255;

      break;

    case 12:  //2 second fade up and down in BLUE

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 108;

      break;

    case 13:  //2 second fade up and down in MAGENTA

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 0;

      break;

    case 14:  //2 second fade up and down in CYAN

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 255;

      break;

    case 15:  //2 second fade up and down in WHITE

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 16:  //2 second fade up and down in MULTICOLOUR

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 17:  //Fast white twinkle in RED

      dmxA = 108;
      dmxB = 108;
      dmxC = 255;
      dmxD = 108;

      break;

    case 18:  //Fast white twinkle in GREEN

      dmxA = 108;
      dmxB = 108;
      dmxC = 255;
      dmxD = 0;

      break;

    case 19:  //Fast white twinkle in YELLOW

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 255;

      break;

    case 20:  //Fast white twinkle in BLUE

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 21:  //Fast white twinkle in MAGENTA

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 22:  //Fast white twinkle in CYAN

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 23:  //Fast white twinkle in WHITE

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 24:  //Fast white twinkle in MULTICOLOUR

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;

    case 25:  //All off with fast twinkle in RED

      dmxA = 0;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 26:  //All off with fast twinkle in GREEN

      dmxA = 0;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 27:  //All off with fast twinkle in YELLOW

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 28:  //All off with fast twinkle in BLUE

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 29:  //All off with fast twinkle in MAGENTA

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;

    case 30:  //All off with fast twinkle in CYAN

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;


      break;

    case 31:  //All off with fast twinkle in WHITE

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 32:  //All off with fast twinkle in MULTICOLOUR

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 33:  //Slow white twinkle on RED

      dmxA = 255;
      dmxB = 0;
      dmxC = 0;
      dmxD = 108;

      break;

    case 34:  //Slow white twinkle on GREEN

      dmxA = 255;
      dmxB = 0;
      dmxC = 0;
      dmxD = 0;

      break;

    case 35:  //Slow white twinkle on YELLOW

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;

      break;

    case 36:  //Slow white twinkle on BLUE

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 37:  //Slow white twinkle on MAGENTA

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 38:  //Slow white twinkle on CYAN

      dmxA = 108;
      dmxB = 0;
      dmxC = 108;
      dmxD = 255;

      break;

    case 39:  //Slow white twinkle on WHITE

      dmxA = 108;
      dmxB = 0;
      dmxC = 108;
      dmxD = 108;

      break;

    case 40:  //Slow white twinkle on MULTICOLOUR

      dmxA = 0;
      dmxB = 0;
      dmxC = 108;
      dmxD = 0;

      break;

    case 41:  //Twinkling slowly to off in RED

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 255;

      break;

    case 42:  //Twinkling slowly to off in GREEN

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 108;

      break;

    case 43:  //Twinkling slowly to off in YELLOW

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 0;

      break;

    case 44:  //Twinkling slowly to off in BLUE

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;

      break;

    case 45:  //Twinkling slowly to off in MAGENTA

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 46:  //Twinkling slowly to off in CYAN

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 47:  //Twinkling slowly to off in WHITE

      dmxA = 0;
      dmxB = 0;
      dmxC = 108;
      dmxD = 255;

      break;

    case 48:  //Twinkling slowly to off in MULTICOLOUR

      dmxA = 0;
      dmxB = 0;
      dmxC = 0;
      dmxD = 255;

      break;

    case 49:  //Off with slow twinkle in RED

      dmxA = 108;
      dmxB = 255;
      dmxC = 255;
      dmxD = 108;

      break;

    case 50:  //Off with slow twinkle in GREEN

      dmxA = 108;
      dmxB = 255;
      dmxC = 255;
      dmxD = 0;

      break;

    case 51:  //Off with slow twinkle in YELLOW

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 255;

      break;

    case 52:  //Off with slow twinkle in BLUE

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 108;

      break;

    case 53:  //Off with slow twinkle in MAGENTA

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 0;

      break;

    case 54:  //Off with slow twinkle in CYAN

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 55:  //Off with slow twinkle in WHITE

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 56:  //Off with slow twinkle in MULTICOLOUR

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;
  } //close
}

Purists and pros will note that I made no attempt to clean up the code, just refactored it for legibility.

Thank you so much for taking the time to look at this, I very much appreciate it.

It didn't compile immediately, I had to change...

void   setdmx(fairyColour) {

to...

void   setdmx(int fairyColour) {

Does that make sense to you?

It didn't fix the issue unfortunately, I will continue with process of elimination...

Any advice would be greatly appreciated....

M

No, that indicates there's a problem.
fairyColour appears in the top comment, and is apparently created elsewhere. Hence, you need to make sure that variable is what's used in the setdmx() function.
To do that, change the call as follows:
setdmx();
and the function declaration line as follows:
void setdmx() {
Remember, I don't have your include files, so can only guess at what's really going on.
That should result in a successful compile, and setdmx should use fairyColour properly.

By the way,

Along the way, I noted that the block of dmx settings to '255' dont have a begin and end transmission, is that correct?

Are you saying you fixed this, but it had no effect? I'm surprised.
Hope this helps; between the obvious 12-hour time difference, and the lack of bits at this end, it's about all I can see.

Hi @camsysca,

Thank you so much for your help, to answer your questions...

This is currently my code and it appears to be working well...

void   setdmx(int fairyColour) {

I do not know why it needs to be defined again but it is working so???

This is the full sketch and it appears to be stable, time will tell.

Along the way, I noted that the block of dmx settings to '255' dont have a begin and end transmission, is that correct?

I did change it, it compiled either way but it does appear to be OK now.

/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/e9b95733-b686-4721-9b4b-544d8f212e9a

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  int fairyColour;
  int stripColour;
  CloudSchedule hbSched;
  CloudSchedule onTime;
  bool heartbeat;
  bool power;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

const int hbPin = 8;
const int statusA = 2;
const int statusB = 3;
const int statusC = 4;
const int testPin = 6;
const int universeSize = 50;
unsigned long lastToggleTime = 0;
bool statusBState = false;
const unsigned long interval = 5 * 1000;  // Delay interval in milliseconds
unsigned long previousMillis = 0;
int currentState = 0;

int dmxA = 255;
int dmxB = 255;
int dmxC = 108;
int dmxD = 108;

int stripR = 0;
int stripG = 0;
int stripB = 255;

#include <Adafruit_NeoPixel.h>

// ArduinoRS485 - Version: Latest
#include <ArduinoRS485.h>

// ArduinoDMX - Version: Latest
#include <ArduinoDMX.h>

#include "thingProperties.h"

#define PIN        7

#define NUMPIXELS 50

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  pinMode(hbPin, OUTPUT);
  pinMode(statusA, OUTPUT);
  pinMode(statusB, OUTPUT);
  pinMode(statusC, OUTPUT);
  pinMode(testPin, OUTPUT);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();

  DMX.begin(universeSize); // initialize the DMX library with the universe size

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)

}

void dmxw(int v) {
  switch (v) {
    case 1:
      DMX.beginTransmission();
      DMX.write(1, 0);
      DMX.write(2, 0);
      DMX.write(3, 0);
      DMX.write(4, 0);
      DMX.write(5, 0);
      DMX.write(6, 0);
      DMX.write(7, 0);
      DMX.write(8, 0);
      DMX.write(9, 0);
      DMX.write(10, 0);
      DMX.write(11, 0);
      DMX.write(12, 0);
      DMX.write(13, 0);
      DMX.write(14, 0);
      DMX.write(15, 0);
      DMX.write(16, 0);
      DMX.write(17, 0);
      DMX.write(18, 0);
      DMX.write(19, 0);
      DMX.write(20, 0);
      DMX.endTransmission();
      break;
    case 2:
      DMX.beginTransmission();
      DMX.write(1, dmxA);
      DMX.write(2, dmxB);
      DMX.write(3, dmxC);
      DMX.write(4, dmxD);
      DMX.write(5, dmxA);
      DMX.write(6, dmxB);
      DMX.write(7, dmxC);
      DMX.write(8, dmxD);
      DMX.write(9, dmxA);
      DMX.write(10, dmxB);
      DMX.write(11, dmxC);
      DMX.write(12, dmxD);
      DMX.write(13, dmxA);
      DMX.write(14, dmxB);
      DMX.write(15, dmxC);
      DMX.write(16, dmxD);
      DMX.write(17, dmxA);
      DMX.write(18, dmxB);
      DMX.write(19, dmxC);
      DMX.write(20, dmxD);
      DMX.endTransmission();
      break;
    case 3:
      DMX.beginTransmission();
      DMX.write(1, 255);
      DMX.write(2, 255);
      DMX.write(3, 255);
      DMX.write(4, 255);
      DMX.write(5, 255);
      DMX.write(6, 255);
      DMX.write(7, 255);
      DMX.write(8, 255);
      DMX.write(9, 255);
      DMX.write(10, 255);
      DMX.write(11, 255);
      DMX.write(12, 255);
      DMX.write(13, 255);
      DMX.write(14, 255);
      DMX.write(15, 255);
      DMX.write(16, 255);
      DMX.write(17, 255);
      DMX.write(18, 255);
      DMX.write(19, 255);
      DMX.write(20, 255);
      DMX.endTransmission();
      break;
  }
}

void   setdmx(int fairyColour) {
  switch (fairyColour) {
    case 1:  //Static Red
      dmxA = 255;
      dmxB = 255;
      dmxC = 255;
      dmxD = 108;
      break;
    case 2:  //Static Green
      dmxA = 255;
      dmxB = 255;
      dmxC = 255;
      dmxD = 0;
      break;
    case 3:  //Static Yellow
      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 255;
      break;
    case 4:  //Static Blue

      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 108;

      break;

    case 5:  //Static Magenta

      dmxA = 255;
      dmxB = 255;
      dmxC = 108;
      dmxD = 0;

      break;

    case 6:  //Static Cyan

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 255;

      break;

    case 7:  //Static White

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 108;

      break;

    case 8:  //Static Multicoloured

      dmxA = 255;
      dmxB = 255;
      dmxC = 0;
      dmxD = 0;

      break;

    case 9:  //2 second fade up and down in RED

      dmxA = 0;
      dmxB = 255;
      dmxC = 0;
      dmxD = 108;

      break;

    case 10:  //2 second fade up and down in GREEN

      dmxA = 0;
      dmxB = 255;
      dmxC = 0;
      dmxD = 0;

      break;

    case 11:  //2 second fade up and down in YELLOW

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 255;

      break;

    case 12:  //2 second fade up and down in BLUE

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 108;

      break;

    case 13:  //2 second fade up and down in MAGENTA

      dmxA = 255;
      dmxB = 108;
      dmxC = 255;
      dmxD = 0;

      break;

    case 14:  //2 second fade up and down in CYAN

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 255;

      break;

    case 15:  //2 second fade up and down in WHITE

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 16:  //2 second fade up and down in MULTICOLOUR

      dmxA = 255;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 17:  //Fast white twinkle in RED

      dmxA = 108;
      dmxB = 108;
      dmxC = 255;
      dmxD = 108;

      break;

    case 18:  //Fast white twinkle in GREEN

      dmxA = 108;
      dmxB = 108;
      dmxC = 255;
      dmxD = 0;

      break;

    case 19:  //Fast white twinkle in YELLOW

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 255;

      break;

    case 20:  //Fast white twinkle in BLUE

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 21:  //Fast white twinkle in MAGENTA

      dmxA = 108;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 22:  //Fast white twinkle in CYAN

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 23:  //Fast white twinkle in WHITE

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 24:  //Fast white twinkle in MULTICOLOUR

      dmxA = 108;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;

    case 25:  //All off with fast twinkle in RED

      dmxA = 0;
      dmxB = 108;
      dmxC = 108;
      dmxD = 108;

      break;

    case 26:  //All off with fast twinkle in GREEN

      dmxA = 0;
      dmxB = 108;
      dmxC = 108;
      dmxD = 0;

      break;

    case 27:  //All off with fast twinkle in YELLOW

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 28:  //All off with fast twinkle in BLUE

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 29:  //All off with fast twinkle in MAGENTA

      dmxA = 0;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;

    case 30:  //All off with fast twinkle in CYAN

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;


      break;

    case 31:  //All off with fast twinkle in WHITE

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 32:  //All off with fast twinkle in MULTICOLOUR

      dmxA = 255;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 33:  //Slow white twinkle on RED

      dmxA = 255;
      dmxB = 0;
      dmxC = 0;
      dmxD = 108;

      break;

    case 34:  //Slow white twinkle on GREEN

      dmxA = 255;
      dmxB = 0;
      dmxC = 0;
      dmxD = 0;

      break;

    case 35:  //Slow white twinkle on YELLOW

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;

      break;

    case 36:  //Slow white twinkle on BLUE

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 37:  //Slow white twinkle on MAGENTA

      dmxA = 108;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 38:  //Slow white twinkle on CYAN

      dmxA = 108;
      dmxB = 0;
      dmxC = 108;
      dmxD = 255;

      break;

    case 39:  //Slow white twinkle on WHITE

      dmxA = 108;
      dmxB = 0;
      dmxC = 108;
      dmxD = 108;

      break;

    case 40:  //Slow white twinkle on MULTICOLOUR

      dmxA = 0;
      dmxB = 0;
      dmxC = 108;
      dmxD = 0;

      break;

    case 41:  //Twinkling slowly to off in RED

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 255;

      break;

    case 42:  //Twinkling slowly to off in GREEN

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 108;

      break;

    case 43:  //Twinkling slowly to off in YELLOW

      dmxA = 108;
      dmxB = 0;
      dmxC = 0;
      dmxD = 0;

      break;

    case 44:  //Twinkling slowly to off in BLUE

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 255;

      break;

    case 45:  //Twinkling slowly to off in MAGENTA

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 108;

      break;

    case 46:  //Twinkling slowly to off in CYAN

      dmxA = 0;
      dmxB = 0;
      dmxC = 255;
      dmxD = 0;

      break;

    case 47:  //Twinkling slowly to off in WHITE

      dmxA = 0;
      dmxB = 0;
      dmxC = 108;
      dmxD = 255;

      break;

    case 48:  //Twinkling slowly to off in MULTICOLOUR

      dmxA = 0;
      dmxB = 0;
      dmxC = 0;
      dmxD = 255;

      break;

    case 49:  //Off with slow twinkle in RED

      dmxA = 108;
      dmxB = 255;
      dmxC = 255;
      dmxD = 108;

      break;

    case 50:  //Off with slow twinkle in GREEN

      dmxA = 108;
      dmxB = 255;
      dmxC = 255;
      dmxD = 0;

      break;

    case 51:  //Off with slow twinkle in YELLOW

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 255;

      break;

    case 52:  //Off with slow twinkle in BLUE

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 108;

      break;

    case 53:  //Off with slow twinkle in MAGENTA

      dmxA = 0;
      dmxB = 255;
      dmxC = 108;
      dmxD = 0;

      break;

    case 54:  //Off with slow twinkle in CYAN

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 255;

      break;

    case 55:  //Off with slow twinkle in WHITE

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 108;

      break;

    case 56:  //Off with slow twinkle in MULTICOLOUR

      dmxA = 255;
      dmxB = 108;
      dmxC = 0;
      dmxD = 0;

      break;
  } //close
}

void stripC() {
      switch (stripColour) {
      case 1: //red
        stripR = 255;
        stripG = 0;
        stripB = 0;
        break;
      case 2: //green
        stripR = 0;
        stripG = 255;
        stripB = 0;
        break;
      case 3: //yellow
        stripR = 255;
        stripG = 255;
        stripB = 0;
        break;
      case 4: //blue
        stripR = 0;
        stripG = 0;
        stripB = 255;
        break;
      case 5: //magenta
        stripR = 255;
        stripG = 0;
        stripB = 255;
        break;
      case 6: //cyan
        stripR = 0;
        stripG = 255;
        stripB = 255;
        break;
      case 7: //white
        stripR = 255;
        stripG = 255;
        stripB = 255;
        break;
    }
}

void stripO() {
  
    stripR = 0;
    stripG = 0;
    stripB = 0;
    
}

void loop() {
  ArduinoCloud.update();
  // Your code here

  setdmx(fairyColour);

  if (fairyColour == 1) {

    digitalWrite(testPin, HIGH);
  }
  else {

    digitalWrite(testPin, LOW);
  }


  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) { // Code to refresh DMX for Subs
    previousMillis = currentMillis;
    dmxw(1);  //set dmx to zero
  }
  
  else {

  if (onTime.isActive()) {
    power = true;
    digitalWrite(statusC, HIGH);
    dmxw(2);  //set dmx to values
    stripC();
  }
  else {  //Set DMX output to OFF
    dmxw(3);  //set dmx to 255
    power = false;
    stripO();
  }
  
  }

  if (hbSched.isActive()) {
    heartbeat = true;
    digitalWrite(hbPin, HIGH);
    //digitalWrite(statusA, HIGH);
  } else {
    heartbeat = false;
    digitalWrite(hbPin, LOW);
    //digitalWrite(statusA, LOW);
  }

  if (millis() - lastToggleTime >= 500) {
    lastToggleTime = millis();
    statusBState = !statusBState;
    digitalWrite(statusB, statusBState);
  }

  pixels.clear();

  pixels.setPixelColor(0, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(1, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(2, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(3, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(4, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(5, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(6, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(7, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(8, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(9, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(10, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(11, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(12, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(13, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(14, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(15, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(16, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(17, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(18, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(19, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(20, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(21, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(22, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(23, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(24, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(25, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(26, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(27, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(28, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(29, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(30, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(31, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(32, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(33, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(34, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(35, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(36, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(37, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(38, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(39, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(40, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(41, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(42, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(43, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(44, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(45, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(46, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(47, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(48, pixels.Color(stripB, stripR, stripG));
  pixels.setPixelColor(49, pixels.Color(stripB, stripR, stripG));

  pixels.show();

}

/*
  Since Power is READ_WRITE variable, onPowerChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onPowerChange()  {
  // Add your code here to act upon Power change
}

/*
  Since FairyColour is READ_WRITE variable, onFairyColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onFairyColourChange()  {
  // Add your code here to act upon FairyColour change
}

/*
  Since StripColour is READ_WRITE variable, onStripColourChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onStripColourChange()  {
  // Add your code here to act upon StripColour change
}

/*
  Since Heartbeat is READ_WRITE variable, onHeartbeatChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHeartbeatChange()  {
  // Add your code here to act upon Heartbeat change
}

/*
  Since HbSched is READ_WRITE variable, onHbSchedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHbSchedChange()  {
  // Add your code here to act upon HbSched change
}

/*
  Since OnTime is READ_WRITE variable, onOnTimeChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onOnTimeChange()  {
  // Add your code here to act upon OnTime change
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.