Go Down

Topic: Arduino Mega Not Running Code (Read 348 times) previous topic - next topic

isaacbrown63

I have an Arduino Mega 2560, it is used for running Christmas lights.  I uploaded my program and ran my sequences, and it ran without a hitch.  I came back the next day, and my program won't upload or run my sequence.  The Tx and Rx flash rapidly and then go off then the channel 13 LED blinks three times, and then nothing.  I try to run my sequences but it does not work.

Any help is appreciated.


ballscrewbob

Unknown code with unknown schematics are exceptionally hard to problem solve.

Respectfully you should READ THIS FIRST

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

isaacbrown63

Here is the code. The 0-15 outputs go to relays. It is powered through the usb.  It is comm port 5 and it is selected.
Code: [Select]

/*
  This sketch allows the Arduino to read 16 bytes of data from Vixen and turn on
  its pins accordingly, which in turn controls a solid state relay hooked up to Xmas lights.
*/

// Define pins on Arduino that will control the relay.
#define CHANNEL_01 1
#define CHANNEL_02 2
#define CHANNEL_03 3
#define CHANNEL_04 4
#define CHANNEL_05 5
#define CHANNEL_06 6
#define CHANNEL_07 7
#define CHANNEL_08 8
#define CHANNEL_09 9
#define CHANNEL_10 10
#define CHANNEL_11 11
#define CHANNEL_12 12
#define CHANNEL_13 13
#define CHANNEL_14 14
#define CHANNEL_15 13
#define CHANNEL_16 15

// Define size of array to hold channels
#define CHANNEL_COUNT 16

// Define array to hold channels
int channels[] =
{
  CHANNEL_01, CHANNEL_02, CHANNEL_03, CHANNEL_04, CHANNEL_05, CHANNEL_06, CHANNEL_07, CHANNEL_08,
  CHANNEL_09, CHANNEL_10, CHANNEL_11, CHANNEL_12, CHANNEL_13, CHANNEL_14, CHANNEL_15, CHANNEL_16
};

// Define array to hold incoming data stream from Vixen
int incomingByte[16];

// Define baud rate. This figure must match that of your profile configuration in Vixen!
#define BAUD_RATE 57600

void setup()
{
  // Begin serial communication
  Serial.begin(BAUD_RATE);

  // Set up each channel as an output
  for (int i = 0; i < CHANNEL_COUNT; i++)
  {
    pinMode(channels[i], OUTPUT);
  }
}

void loop()
{
  if (Serial.available() >= CHANNEL_COUNT)
  {
    // Read data from Vixen, store in array
    for (int i = 0; i < CHANNEL_COUNT; i++)
    {
      incomingByte[i] = Serial.read();
    }
    // Write data from array to a pin on Arduino
    for (int i = 0; i < CHANNEL_COUNT; i++)
    {
      digitalWrite(channels[i], incomingByte[i]);
    }
  }
}


ballscrewbob

#3
Dec 14, 2017, 01:02 am Last Edit: Dec 14, 2017, 01:09 am by ballscrewbob
Whats a vixen and how is everything powered (schematic).

BTW why is there a reason for the section.

#define CHANNEL_13 13 <
#define CHANNEL_14 14
#define CHANNEL_15 13 < called twice
#define CHANNEL_16 15 < should it not be 16 ?

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up