Halloween Project - happy to pay for help...Please!

In way over my head with something I am sure is fairlly straightforward for someone familiar with this product. Happy to pay for your time to walk me through accomplishing this project.

We are making the Beetlejuice sign for our Halloween display and following this tutorial: https://www.tominseattle.com/post/animated-beetlejuice-graveyard-sign

We purchased ALL products he listed including:
Arduino Mega 2560
Sainsmart 16-Channel Relay
20-pin ribbon cable
Power Distribution Block
12V power supply (for relays
9V power supply (for LED light strips

I downloaded the Adruino program to my macbook pro and I do get green light when I connect to my computer.

When I copy and past the code into sketch I get error messages and I am not skilled enough to know what to do next. HELP! I am sure someone with experience would have this done in the blink of an eye. I would love to have you wallk me through it via a video chat so we can check this project of the list!

Here is the text of the code I am trying to use: //BeetleJuice_Sign.ino
//
//Here are the pin mappings
//
//B1 -> Relay 1 -> Arduino Pin 44
//B2 -> Relay 2 -> Arduino Pin 43
//B3 -> Relay 3 -> Arduino Pin 42
//A1 -> Relay 4 -> Arduino Pin 41
//A2 -> Relay 5 -> Arduino Pin 40
//A3 -> Relay 6 -> Arduino Pin 39
//A4 -> Relay 7 -> Arduino Pin 38
//A5 -> Relay 8 -> Arduino Pin 37
//A6 -> Relay 9 -> Arduino Pin 36
//A7 -> Relay 10 -> Arduino Pin 35
//A8 -> Relay 11 -> Arduino Pin 34
//A9 -> Relay 12 -> Arduino Pin 33
//A10 -> Relay 13 -> Arduino Pin 32
//A11 -> Relay 14 -> Arduino Pin 31
//LED -> Relay 15 -> Arduino Pin 30

int ON = LOW;
int OFF = HIGH;

int frameArray[] = {44, 43, 42};
int frameCount = 3;
int frameIndex = 0;
unsigned long frameMillis = 0;
int frameInterval = 500; //msecs

int arrowArray[] = {41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31};
int arrowCount = 11;
int arrowIndex = 0;
unsigned long arrowMillis = 0;
int arrowInterval = 250; //msecs
int arrowPhase = 0;

int ledSwitch = 30; //main sign count
int ledState = OFF;
unsigned long ledMillis = 0;
int ledOnTime = 1000; //msecs
int ledOffTime = 500; //msecs

void doArrow(unsigned long currentMillis)
{
if (currentMillis - arrowMillis >= arrowInterval)
{
arrowMillis += arrowInterval;
digitalWrite(arrowArray[arrowIndex], (arrowPhase == 0) ? ON : OFF);
arrowIndex = (arrowIndex + 1) % arrowCount;
arrowPhase = (arrowIndex == 0) ? !arrowPhase : arrowPhase;
}
}

void doFrame(unsigned long currentMillis)
{
if (currentMillis - frameMillis > frameInterval)
{
frameMillis = currentMillis;
digitalWrite(frameArray[frameIndex], OFF);
frameIndex = (frameIndex + 1) % frameCount;
digitalWrite(frameArray[frameIndex], ON);
}
}

void doLedSwitch(unsigned long currentMillis)
{
if (ledState == ON && currentMillis - ledMillis > ledOffTime)
{
ledMillis = currentMillis;
ledState = OFF;
digitalWrite(ledSwitch, ledState);
}
else
if (ledState == OFF && currentMillis - ledMillis > ledOnTime)
{
ledMillis = currentMillis;
ledState = ON;
digitalWrite(ledSwitch, ledState);;
}
}

void setup()
{
for (int count = 0; count < arrowCount; count++)
{
pinMode(arrowArray[count], OUTPUT);
digitalWrite(arrowArray[count], OFF);
}

for (int count = 0; count < frameCount; count++)
{
	pinMode(frameArray[count], OUTPUT);
		digitalWrite(frameArray[count], OFF);
}

pinMode(ledSwitch, OUTPUT);
digitalWrite(ledSwitch, OFF);

}

void loop()
{
unsigned long currentMillis = millis();
doArrow(currentMillis);
doFrame(currentMillis);
doLedSwitch(currentMillis);
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your sketch, using code tags when you do

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Please also post the full error message that you get when compiling the code

The sketch compiles OK for me

void setup() {
  // put your setup code here, to run once:
  //BeetleJuice_Sign.ino
  //
  //Here are the pin mappings
  //
  //B1  -> Relay 1   -> Arduino Pin 44
  //B2  -> Relay 2   -> Arduino Pin 43
  //B3  -> Relay 3   -> Arduino Pin 42
  //A1  -> Relay 4   -> Arduino Pin 41
  //A2  -> Relay 5   -> Arduino Pin 40
  //A3  -> Relay 6   -> Arduino Pin 39
  //A4  -> Relay 7   -> Arduino Pin 38
  //A5  -> Relay 8   -> Arduino Pin 37
  //A6  -> Relay 9   -> Arduino Pin 36
  //A7  -> Relay 10  -> Arduino Pin 35
  //A8  -> Relay 11  -> Arduino Pin 34
  //A9  -> Relay 12  -> Arduino Pin 33
  //A10 -> Relay 13  -> Arduino Pin 32
  //A11 -> Relay 14  -> Arduino Pin 31
  //LED -> Relay 15  -> Arduino Pin 30

  int ON = LOW;
  int OFF = HIGH;

  int frameArray[] = {44, 43, 42};
  int frameCount = 3;
  int frameIndex = 0;
  unsigned long frameMillis = 0;
  int frameInterval = 500;   //msecs

  int arrowArray[] = {41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31};
  int arrowCount = 11;
  int arrowIndex = 0;
  unsigned long arrowMillis = 0;
  int arrowInterval = 250;   //msecs
  int arrowPhase = 0;

  int ledSwitch = 30; //main sign count
  int ledState = OFF;
  unsigned long ledMillis = 0;
  int ledOnTime = 1000;    //msecs
  int ledOffTime = 500;    //msecs

  void doArrow(unsigned long currentMillis)
  {
    if (currentMillis - arrowMillis >= arrowInterval)
    {
      arrowMillis += arrowInterval;
      digitalWrite(arrowArray[arrowIndex], (arrowPhase == 0) ? ON : OFF);
      arrowIndex = (arrowIndex + 1) % arrowCount;
      arrowPhase = (arrowIndex == 0) ? !arrowPhase : arrowPhase;
    }
  }

  void doFrame(unsigned long currentMillis)
  {
    if (currentMillis - frameMillis > frameInterval)
    {
      frameMillis = currentMillis;
      digitalWrite(frameArray[frameIndex], OFF);
      frameIndex = (frameIndex + 1) % frameCount;
      digitalWrite(frameArray[frameIndex], ON);
    }
  }

  void doLedSwitch(unsigned long currentMillis)
  {
    if (ledState == ON && currentMillis - ledMillis > ledOffTime)
    {
      ledMillis = currentMillis;
      ledState = OFF;
      digitalWrite(ledSwitch, ledState);
    }
    else if (ledState == OFF && currentMillis - ledMillis > ledOnTime)
    {
      ledMillis = currentMillis;
      ledState = ON;
      digitalWrite(ledSwitch, ledState);;
    }
  }

  void setup()
  {
    for (int count = 0; count < arrowCount; count++)
    {
      pinMode(arrowArray[count], OUTPUT);
      digitalWrite(arrowArray[count], OFF);
    }

    for (int count = 0; count < frameCount; count++)
    {
      pinMode(frameArray[count], OUTPUT);
      digitalWrite(frameArray[count], OFF);
    }

    pinMode(ledSwitch, OUTPUT);
    digitalWrite(ledSwitch, OFF);
  }

  void loop()
  {
    unsigned long currentMillis = millis();
    doArrow(currentMillis);
    doFrame(currentMillis);
    doLedSwitch(currentMillis);
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}
Arduino: 1.8.19 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"











/Users/sarahabrams/Documents/Arduino/sketch_sep03e/sketch_sep03e.ino: In function 'void setup()':
sketch_sep03e:46:3: error: a function-definition is not allowed here before '{' token
   {
   ^
sketch_sep03e:57:3: error: a function-definition is not allowed here before '{' token
   {
   ^
sketch_sep03e:68:3: error: a function-definition is not allowed here before '{' token
   {
   ^
sketch_sep03e:84:3: error: a function-definition is not allowed here before '{' token
   {
   ^
sketch_sep03e:102:3: error: a function-definition is not allowed here before '{' token
   {
   ^
exit status 1
a function-definition is not allowed here before '{' token


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The two sketches are not the same. In the latest one posted the brace at the end of the doArrow() function is missing, hence the errors

Here is your original code in code tags. It compiles for me

//BeetleJuice_Sign.ino
//
//Here are the pin mappings
//
//B1 -> Relay 1 -> Arduino Pin 44
//B2 -> Relay 2 -> Arduino Pin 43
//B3 -> Relay 3 -> Arduino Pin 42
//A1 -> Relay 4 -> Arduino Pin 41
//A2 -> Relay 5 -> Arduino Pin 40
//A3 -> Relay 6 -> Arduino Pin 39
//A4 -> Relay 7 -> Arduino Pin 38
//A5 -> Relay 8 -> Arduino Pin 37
//A6 -> Relay 9 -> Arduino Pin 36
//A7 -> Relay 10 -> Arduino Pin 35
//A8 -> Relay 11 -> Arduino Pin 34
//A9 -> Relay 12 -> Arduino Pin 33
//A10 -> Relay 13 -> Arduino Pin 32
//A11 -> Relay 14 -> Arduino Pin 31
//LED -> Relay 15 -> Arduino Pin 30

int ON = LOW;
int OFF = HIGH;

int frameArray[] = { 44, 43, 42 };
int frameCount = 3;
int frameIndex = 0;
unsigned long frameMillis = 0;
int frameInterval = 500;  //msecs

int arrowArray[] = { 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31 };
int arrowCount = 11;
int arrowIndex = 0;
unsigned long arrowMillis = 0;
int arrowInterval = 250;  //msecs
int arrowPhase = 0;

int ledSwitch = 30;  //main sign count
int ledState = OFF;
unsigned long ledMillis = 0;
int ledOnTime = 1000;  //msecs
int ledOffTime = 500;  //msecs

void doArrow(unsigned long currentMillis)
{
    if (currentMillis - arrowMillis >= arrowInterval)
    {
        arrowMillis += arrowInterval;
        digitalWrite(arrowArray[arrowIndex], (arrowPhase == 0) ? ON : OFF);
        arrowIndex = (arrowIndex + 1) % arrowCount;
        arrowPhase = (arrowIndex == 0) ? !arrowPhase : arrowPhase;
    }
}

void doFrame(unsigned long currentMillis)
{
    if (currentMillis - frameMillis > frameInterval)
    {
        frameMillis = currentMillis;
        digitalWrite(frameArray[frameIndex], OFF);
        frameIndex = (frameIndex + 1) % frameCount;
        digitalWrite(frameArray[frameIndex], ON);
    }
}

void doLedSwitch(unsigned long currentMillis)
{
    if (ledState == ON && currentMillis - ledMillis > ledOffTime)
    {
        ledMillis = currentMillis;
        ledState = OFF;
        digitalWrite(ledSwitch, ledState);
    }
    else if (ledState == OFF && currentMillis - ledMillis > ledOnTime)
    {
        ledMillis = currentMillis;
        ledState = ON;
        digitalWrite(ledSwitch, ledState);
        ;
    }
}

void setup()
{
    for (int count = 0; count < arrowCount; count++)
    {
        pinMode(arrowArray[count], OUTPUT);
        digitalWrite(arrowArray[count], OFF);
    }

    for (int count = 0; count < frameCount; count++)
    {
        pinMode(frameArray[count], OUTPUT);
        digitalWrite(frameArray[count], OFF);
    }

    pinMode(ledSwitch, OUTPUT);
    digitalWrite(ledSwitch, OFF);
}

void loop()
{
    unsigned long currentMillis = millis();
    doArrow(currentMillis);
    doFrame(currentMillis);
    doLedSwitch(currentMillis);
}

code from post #4 with

  • extra setup() and loop() removed
  • maye some braces fixed
  • timer variables made unsigned long to avoid warnings
// put your setup code here, to run once:
//BeetleJuice_Sign.ino
//
//Here are the pin mappings
//
//B1  -> Relay 1   -> Arduino Pin 44
//B2  -> Relay 2   -> Arduino Pin 43
//B3  -> Relay 3   -> Arduino Pin 42
//A1  -> Relay 4   -> Arduino Pin 41
//A2  -> Relay 5   -> Arduino Pin 40
//A3  -> Relay 6   -> Arduino Pin 39
//A4  -> Relay 7   -> Arduino Pin 38
//A5  -> Relay 8   -> Arduino Pin 37
//A6  -> Relay 9   -> Arduino Pin 36
//A7  -> Relay 10  -> Arduino Pin 35
//A8  -> Relay 11  -> Arduino Pin 34
//A9  -> Relay 12  -> Arduino Pin 33
//A10 -> Relay 13  -> Arduino Pin 32
//A11 -> Relay 14  -> Arduino Pin 31
//LED -> Relay 15  -> Arduino Pin 30


int ON = LOW;
int OFF = HIGH;

int frameArray[] = {44, 43, 42};
int frameCount = 3;
int frameIndex = 0;
unsigned long frameMillis = 0;
unsigned long frameInterval = 500;   //msecs

int arrowArray[] = {41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31};
int arrowCount = 11;
int arrowIndex = 0;
unsigned long arrowMillis = 0;
unsigned long arrowInterval = 250;   //msecs
int arrowPhase = 0;

int ledSwitch = 30; //main sign count
int ledState = OFF;
unsigned long ledMillis = 0;
unsigned long ledOnTime = 1000;    //msecs
unsigned long ledOffTime = 500;    //msecs

void doArrow(unsigned long currentMillis)
{
    if (currentMillis - arrowMillis >= arrowInterval)
    {
        arrowMillis += arrowInterval;
        digitalWrite(arrowArray[arrowIndex], (arrowPhase == 0) ? ON : OFF);
        arrowIndex = (arrowIndex + 1) % arrowCount;
        arrowPhase = (arrowIndex == 0) ? !arrowPhase : arrowPhase;
    }
}


void doFrame(unsigned long currentMillis)
{
    if (currentMillis - frameMillis > frameInterval)
    {
        frameMillis = currentMillis;
        digitalWrite(frameArray[frameIndex], OFF);
        frameIndex = (frameIndex + 1) % frameCount;
        digitalWrite(frameArray[frameIndex], ON);
    }
}


void doLedSwitch(unsigned long currentMillis)
{
    if (ledState == ON && currentMillis - ledMillis > ledOffTime)
    {
        ledMillis = currentMillis;
        ledState = OFF;
        digitalWrite(ledSwitch, ledState);
    }
    else if (ledState == OFF && currentMillis - ledMillis > ledOnTime)
    {
        ledMillis = currentMillis;
        ledState = ON;
        digitalWrite(ledSwitch, ledState);
    }
}


void setup()
{
    for (int count = 0; count < arrowCount; count++)
    {
        pinMode(arrowArray[count], OUTPUT);
        digitalWrite(arrowArray[count], OFF);
    }

    for (int count = 0; count < frameCount; count++)
    {
        pinMode(frameArray[count], OUTPUT);
        digitalWrite(frameArray[count], OFF);
    }

    pinMode(ledSwitch, OUTPUT);
    digitalWrite(ledSwitch, OFF);
}


void loop()
{
    unsigned long currentMillis = millis();
    doArrow(currentMillis);
    doFrame(currentMillis);
    doLedSwitch(currentMillis);
}

you better delete old sketch before you

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