Arduino Forum

Using Arduino => Installation & Troubleshooting => Topic started by: isaacbrown63 on Dec 13, 2017, 10:13 pm

Title: Arduino Mega Not Running Code
Post by: isaacbrown63 on Dec 13, 2017, 10:13 pm
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.

Title: Re: Arduino Mega Not Running Code
Post by: ballscrewbob on Dec 13, 2017, 11:07 pm
Unknown code with unknown schematics are exceptionally hard to problem solve.

Respectfully you should READ THIS FIRST (http://forum.arduino.cc/index.php?topic=148850.0)

Title: Re: Arduino Mega Not Running Code
Post by: isaacbrown63 on Dec 14, 2017, 12:17 am
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]);
    }
  }
}

Title: Re: Arduino Mega Not Running Code
Post by: ballscrewbob on Dec 14, 2017, 01:02 am
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 ?