nightshade-electronics / energyShield2

Arduino library for the NightShade Electronics energyShield 2 Pro
https://ns-electric.com/product/energyshield-2/
MIT License
0 stars 1 forks source link

Compatibility between energyShield2, Tinker DMX, and Adafruit MP3 Music Maker #4

Open nitramor opened 5 years ago

nitramor commented 5 years ago

Hoping you can help with this "last volt" issue. I've been slowly learning and piecing together this project step by step and have made steady progress -- going from not knowing how to solder or program an Arduino to successfully testing a prototype that combines an Arduino Uno, a TinkerIT DMX master, an Adafruit MP3 Music Maker, an energyShield2 Pro, and a button to trigger scenes in a show with audio and lighting cues -- all from a button on my guitar onstage. (see www.MissRainsong.com for the show and music).

I have prototyped almost every combination of shield and power source in various combinations and have successfully gotten them working together except ALL together. When I do the final bundle, I get an error where the SD card is not recognized. I believe the conflict is between the energyShield and the DMX shield because when I add the DMXsimple.h library in an include statement to a working build that has all the other components working, I can get the same error:

When I add the NS_energyShield Include statement, I get the following monitor output and no sound:

Hello simple_mp3_button.ino Adafruit VS1053 Simple Test with button VS1053 found XYXVtto play Setup complete. all lights set to 0 Starting buttonState =0 Read buttonState =0 Set buttonState =0 Ready to play . . . . . . . . . . . . . . Now Playing DONE Playing starting DMX Starting buttonState =0 Read buttonState =0 Set buttonState =0 Ready to play . . . . . . . . . . . . .

When I add the two statements: NS_energyShield2 es2; //and es2.begin(); // in setup,

The setup doesn't recognize the SD card.

Hello simple_mp3_button.ino Afrfruit VS1053 Simple Test with button VS1053 found SD failed, or not present

The way I'm getting it to work right now is to leave out the energyShield library and, I guess, just use it as a dumb battery that has no controls. That's actually okay for this project as I don't need the clock and the other functions right now. But I would like to understand what I might be doing wrong. Here's the prototype code:

`/**** This is a routine to run the lights and sound for the "One-Guitar Show" Miss Isabella Rainsong and Her Traveling Companion by embedding an arduino inside the RainSong guitar used in the performance and triggering the lighting and audio cues with a button hidden on the guitar. The button triggers DMX cues and MP3 audio that is wirelessly sent from the guitar to the light rig and the PA system respectively.

The show and this code have been written and performed by Ross D. Martin
ross@acmimimi.org
www.MissRainsong.com

Hardware:
- Arduino Uno
- Adafruit Music Maker MP3 Player shield
- TinkerKit DMX shield
- NightShade Electronics energyShield Pro2

Wiring:
- Arduino Pin 10 jumps to DMX pin 3 to avoid MP3 conflict
- Arduino Pin 13 goes to LED to GND for LED light (not working)
- 10K resistor from 8 to GND -- sink for button
- Button from 8 to button to 5v
- DMX wireless tranceiver power cable goes to GND (striped neg) and 5v (+)

Software based on:
- DmxSimple DMX_Master
- Adafruit VS1053 player_simple

Overview:
- Each scene represents a portion of the show where there is a lighting cue,
an audio cue, or both.
- Scenes are triggered by pressing a hidden button on the RainSong guitar
used in the performance of the show.
- One press of the button moves to the next scene.
- Two button presses within 1 second moves triggers the prior scene (not finished)
- Three button presses within 2 seconds pauses the program (not finished)
- The Arduino stack is hidden inside the guitar and uses wireless transmitters
to send the DMX and audio signals.

DMX Assignments:
                       Back Wall
           Stage Right Back    Stage Left Back
                -------             -------
               |ch51-53|---same----|ch51-53|
                -------             -------
                   6                   5
   4             3      Blacklight     2              1
-------       -------    --------   -------        -------
ch41-43 ch31-33 ch01-03 ch21-23 ch11-13
                         Front
                        AUDIENCE

Each light has seven DMX channels, but this setup uses only three: Red, Green, Blue -- with
each channel accepting a range of 0 (off) to 255 (100% on). Lights are set to the first channel they are
assigned (1, 8, 15, etc.) and set to 3-Ch. Blacklight has four channels operating four sets of dimmable blacklights.

MP3 Files
Named rainsngX.mp3
X = sequential digit

Thanks to Brian Donnelly for introducing me to Arduino.
Thanks to the many open source folks to posted questions and answers and
videos and diagrams to make this technology dumpster dive adventure possible.
This project was created by Ross Martin between June 10, 2019 and whenever I
decide it's finished-ish.

Many Bothans died to bring us this automation...

***/

//SET-UP

// DmxSimple - Version: Latest // include SPI, MP3 and SD libraries // Adafruit VS1053 Library - Version: Latest // energyShield libraries

include

include

include

include

//#include //#include

// See http://arduino.cc/en/Reference/SPI "Connections"

define BREAKOUT_RESET 9 // VS1053 reset pin (output)

define BREAKOUT_CS 10 // VS1053 chip select pin (output)

define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)

// These are the pins used for the music maker shield

define SHIELD_RESET -1 // VS1053 reset pin (unused!)

define SHIELD_CS 7 // VS1053 chip select pin (output)

define SHIELD_DCS 6 // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield

define CARDCS 4 // Card chip select pin

// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt

define DREQ 3 // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer = // create shield-example object! Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

//NS_energyShield2 es2;

// constants won't change. They're used here to set pin numbers: const int buttonPin = 8; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin

// variables will change: String sceneString; String musicFile;

int buttonState = 0; // variable for reading the pushbutton status int currentScene = 4; // Marks the current scene. Used to build the MP3 filename call int sceneJump = 1; // for moving between scenes with button (can go forward or backward) int brightness; // Current brightness of the light being set int rbright; int gbright; int bbright; int blbright; int fullbright; int halfbright; int dimbright;

void setup() { //es2.begin(); // Initializes the energyShield 2 /* The most common pin for DMX output is pin 3, which DmxSimple uses by default. If you need to change that, do it here. USING 10 to avoid compatibility issues with MP3 Player./ DmxSimple.usePin(10); / DMX devices typically need to receive a complete set of channels even if you only need to adjust the first channel. You can easily change the number of channels sent here. If you don't do this, DmxSimple will set the maximum channel number to the * highest channel you DmxSimple.write() to. / DmxSimple.maxChannel(100); musicPlayer.setVolume(20, 20);
//PRE-CURTAIN Serial.begin(9600); Serial.println(F("Hello")); Serial.println("simple_mp3_button.ino Adafruit VS1053 Simple Test with button"); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); if (! musicPlayer.begin()) { // initialise the music player Serial.println(F("Couldn't find VS1053, do you have the right pins defined?")); while (1); } Serial.println(F("VS1053 found"));

if (!SD.begin(CARDCS)) { Serial.println(F("SD failed, or not present")); while (1); // don't do anything more }

// list files //printDirectory(SD.open("/"), 0);

// Set volume for left, right channels. lower numbers == louder volume! musicPlayer.setVolume(20,20);

// Timer interrupts are not suggested, better to use DREQ interrupt! //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

// If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background // audio playing musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int

/ // Play another file in the background, REQUIRES interrupts! Serial.println(F("Playing track 002")); musicPlayer.startPlayingFile("/track002.mp3");/ //nextScene(sceneJump); Serial.print(F("ready to play ")); Serial.println(musicFile);

Serial.println("Setup complete.");

brightness = 0; dimbright = 10; halfbright = 125; fullbright = 255;

// Reset lights to off //Light 1 (front, stage far L) DmxSimple.write(1, brightness); //red DmxSimple.write(2, brightness); //green DmxSimple.write(3, brightness); //blue //Light 2 (front, stage mid L) DmxSimple.write(11, brightness); //red DmxSimple.write(12, brightness); //green DmxSimple.write(13, brightness); //blue //Light 3 (front, stage mid R) DmxSimple.write(21, brightness); //red DmxSimple.write(22, brightness); //green DmxSimple.write(23, brightness); //blue //Light 4 (front, stage far R) DmxSimple.write(31, brightness); //red DmxSimple.write(32, brightness); //green DmxSimple.write(33, brightness); //blue //Light 5 (rear, stage L) DmxSimple.write(41, brightness); //red DmxSimple.write(42, brightness); //green DmxSimple.write(43, brightness); //blue //Light 6 (rear, stage R) DmxSimple.write(51, brightness); //red DmxSimple.write(52, brightness); //green DmxSimple.write(53, brightness); //blue //Blacklight DmxSimple.write(1, brightness); //Blacklight DmxSimple.write(2, brightness); DmxSimple.write(3, brightness); DmxSimple.write(4, brightness); delay(300);

Serial.println("all lights set to 0"); //Blacklight DmxSimple.write(1, 255); //Blacklight DmxSimple.write(2, 255); DmxSimple.write(3, 255); DmxSimple.write(4, 255); delay(300); DmxSimple.write(1, brightness); //Blacklight DmxSimple.write(2, brightness); DmxSimple.write(3, brightness); DmxSimple.write(4, brightness);

} //SCENE 1 -- Curtain up! void loop() { // waiting for button push / Serial.print("Starting buttonState ="); Serial.println(buttonState); buttonState = digitalRead(buttonPin); Serial.print("Read buttonState ="); Serial.println(buttonState); buttonState = LOW; Serial.print("Set buttonState ="); Serial.println(buttonState); Serial.print(F("Ready to play ")); Serial.println(musicFile); / buttonState = LOW; // check if the pushbutton is pressed. If it is, the buttonState is HIGH: Serial.println("waiting for button"); while (buttonState == LOW) { delay(5);
buttonState = digitalRead(buttonPin); //Serial.print(F(". ")); } // check for reset request (1 second button push). If yes, start scenes from the beginning delay(200); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { currentScene = 6; }

nextScene(sceneJump); // Start playing current file Serial.println(); Serial.print(F("Now Playing ")); Serial.println(musicFile); musicPlayer.startPlayingFile(musicFile.c_str());

delay(100);

Serial.print(F("DONE Playing ")); Serial.println(musicFile); digitalWrite(ledPin, HIGH); brightness = 0; dimbright = 10; halfbright = 125; fullbright = 255; // if (! musicPlayer.begin()) { // initialise the music player // Serial.println(F("Couldn't find VS1053, do you have the right pins defined?")); // while (1); // } // Serial.println(F("VS1053 found"));

/* if (!SD.begin(CARDCS)) { Serial.println(F("SD failed, or not present")); while (1); // don't do anything more }

// list files // printDirectory(SD.open("/"), 0);

// Set volume for left, right channels. lower numbers == louder volume! musicPlayer.setVolume(20, 20);

// Timer interrupts are not suggested, better to use DREQ interrupt! //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

// If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background // audio playing musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int

// Play one file, don't return until complete Serial.println(F("Playing 1"));

// musicPlayer.playFullFile("rainsng1.mp3"); if (! musicPlayer.startPlayingFile("/rainsng1.mp3")) { Serial.println("Could not open file rainsng11.mp3"); while (1); } Serial.println(F("Started playing"));

while (musicPlayer.playingMusic) { // file is now playing in the 'background' so now's a good time // to do something else like handling LEDs or buttons :) Serial.print("."); delay(1000);

Serial.println("still playing music");

Serial.println("Playing 1");
//  musicPlayer.startPlayingFile("/rainsng1.mp3");
//  musicPlayer.playFullFile("/rainsng1.mp3");*/
Serial.println(F("starting DMX"));
brightness = 0;
while(brightness <=255) {
  //Light 1 (front, stage far L)
  DmxSimple.write(1, brightness); //red
  DmxSimple.write(2, brightness); //green
  DmxSimple.write(3, brightness); //blue
  //Light 2 (front, stage mid L)
  DmxSimple.write(11, brightness); //red
  DmxSimple.write(12, brightness); //green
  DmxSimple.write(13, brightness); //blue
  //Light 3 (front, stage mid R)
  DmxSimple.write(21, brightness); //red
  DmxSimple.write(22, brightness); //green
  DmxSimple.write(23, brightness); //blue
  //Light 4 (front, stage far R)
  DmxSimple.write(31, brightness); //red
  DmxSimple.write(32, brightness); //green
  DmxSimple.write(33, brightness); //blue
  //Light 5 (rear, stage L)
  DmxSimple.write(41, brightness); //red
  DmxSimple.write(42, brightness); //green
  DmxSimple.write(43, brightness); //blue
  //Light 6 (rear, stage R)
  DmxSimple.write(51, brightness); //red
  DmxSimple.write(52, brightness); //green
  DmxSimple.write(53, brightness); //blue
  //Blacklight
  DmxSimple.write(1, brightness); //Blacklight
  DmxSimple.write(2, brightness); 
  DmxSimple.write(3, brightness); 
  DmxSimple.write(4, brightness); 
  delay(10);
  brightness++;
}
delay(2000);
while(brightness >=0) {
  //Light 1 (front, stage far L)
  //DmxSimple.write(1, brightness); //red
  DmxSimple.write(2, brightness); //green
  DmxSimple.write(3, brightness); //blue
  //Light 2 (front, stage mid L)
  DmxSimple.write(11, brightness); //red
  //DmxSimple.write(12, brightness); //green
  DmxSimple.write(13, brightness); //blue
  //Light 3 (front, stage mid R)
  DmxSimple.write(21, brightness); //red
  DmxSimple.write(22, brightness); //green
  //DmxSimple.write(23, brightness); //blue
  //Light 4 (front, stage far R)
  DmxSimple.write(31, brightness); //red
  DmxSimple.write(32, brightness); //green
  DmxSimple.write(33, brightness); //blue
  //Light 5 (rear, stage L)
  //DmxSimple.write(41, brightness); //red
  DmxSimple.write(42, brightness); //green
  //DmxSimple.write(43, brightness); //blue
  //Light 6 (rear, stage R)
  //DmxSimple.write(51, brightness); //red
  //DmxSimple.write(52, brightness); //green
  DmxSimple.write(53, brightness); //blue
  //Blacklight
  DmxSimple.write(1, brightness); //Blacklight
  DmxSimple.write(2, brightness); 
  DmxSimple.write(3, brightness); 
  DmxSimple.write(4, brightness); 
  delay(10);
  brightness--;
}
brightness = 0;

/* if (! musicPlayer.begin()) { // initialise the music player Serial.println(F("Couldn't find VS1053, do you have the right pins defined?")); while (1); } Serial.println(F("VS1053 found"));

if (!SD.begin(CARDCS)) {
  Serial.println(F("SD failed, or not present"));
  while (1);  // don't do anything more
}

// list files
//printDirectory(SD.open("/"), 0);

// Set volume for left, right channels. lower numbers == louder volume!
musicPlayer.setVolume(20, 20);

// Timer interrupts are not suggested, better to use DREQ interrupt!
//musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

// If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
// audio playing
musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int

// Play one file, don't return until complete
Serial.println(F("Playing 1"));
musicPlayer.startPlayingFile("/rainsng1.mp3");*/

//DMX lighting signal
while (brightness <= 254) {
  brightness++;
  DmxSimple.write(1, 255); //red
  DmxSimple.write(2, 0);          //green
  DmxSimple.write(3, 25);          //blue
  DmxSimple.write(5, 50);          //Strobe
  DmxSimple.write(7, brightness);        //brightness
  delay(20);
}

while (musicPlayer.playingMusic) { Serial.print(". "); delay(100); } Serial.println("ending DMX"); digitalWrite(ledPin, HIGH); delay(2000); digitalWrite(ledPin, LOW);

}

/// File listing helper void printDirectory(File dir, int numTabs) { while (true) {

File entry =  dir.openNextFile();
if (! entry) {
  // no more files
  //Serial.println("**nomorefiles**");
  break;
}
for (uint8_t i = 0; i < numTabs; i++) {
  Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
  Serial.println("/");
  printDirectory(entry, numTabs + 1);
} else {
  // files have sizes, directories do not
  Serial.print("\t\t");
  Serial.println(entry.size(), DEC);
}
entry.close();

} }

//nextScene: sets up for the following scene by: // setting buttonState to LOW // setting currentScene to ++ // setting mp3 file to next file void nextScene(int jump) { buttonState = 0; currentScene = currentScene + jump; sceneString = String(currentScene); musicFile = String("/T" + String(sceneString) + ".mp3"); } //Text from sources: /*** This is an example for the Adafruit VS1053 Codec Breakout

Designed specifically to work with the Adafruit VS1053 Codec Breakout ----> https://www.adafruit.com/products/1381

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution ****/

/ Welcome to DmxSimple. This library allows you to control DMX stage and architectural lighting and visual effects easily from Arduino. DmxSimple is compatible with the Tinker.it! DMX shield and all known DIY Arduino DMX control circuits. DmxSimple is available from: http://code.google.com/p/tinkerit/ Help and support: http://groups.google.com/group/dmxsimple /

/* To use DmxSimple, you will need the following line. Arduino will * auto-insert it if you select Sketch > Import Library > DmxSimple. /`

aliebold commented 5 years ago

Hi Ross,

I just took another look at this (not on my phone) and I think that you may have some pin assignments overlapping. The SD card reader uses the SPI pins (10, 11, 12, & 13). I noticed that you have your ledpin assigned to pin 13, which might cause an issue somewhere. The energyShield uses the I2C pins SDA & SCL, which are A4 & A5 on an Uno or D2 & D3 on a Leonardo. (SDA/SCL pins connect to other pins on the headers) I believe the DMX controller is also run on the SDA/SCL pins, which could cause a compatibility issue. That’s where you can possibly call the es2.begin() every time before you access its functions, and setup the DMX again every time you’re going to use it.

As a next step, I would overlay all of the pin requirements of your project and see if you can find any conflicts.

Let me know how it goes!

Best regards,

Aaron Liebold

NightShade Electronics

Phone: 321-473-4490 Ext. 103

Email: mailto:aliebold@ns-electric.com aliebold@ns-electric.com

Website: http://ns-electric.com/ http://ns-electric.com

Confidential Notice: The contents of this email and its attachments are the sole property of Liebold Technologies, LLC. No portion of this e-mail and/or correspondence its attachment(s) may be reproduced without written consent of Liebold Technologies, LLC. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. The information contained in this message and or attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient or believe that you may have received this document in error, please notify the sender and delete this e-mail and any attachments immediately.

From: Ross Martin notifications@github.com Sent: Saturday, June 29, 2019 2:26 PM To: nightshade-electronics/energyShield2 energyShield2@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [nightshade-electronics/energyShield2] Compatibility between energyShield2, Tinker DMX, and Adafruit MP3 Music Maker (#4)

Hoping you can help with this "last volt" issue. I've been slowly learning and piecing together this project step by step and have made steady progress -- going from not knowing how to solder or program an Arduino to successfully testing a prototype that combines an Arduino Uno, a TinkerIT DMX master, an Adafruit MP3 Music Maker, an energyShield2 Pro, and a button to trigger scenes in a show with audio and lighting cues -- all from a button on my guitar onstage. (see www.MissRainsong.com http://www.MissRainsong.com for the show and music).

I have prototyped almost every combination of shield and power source in various combinations and have successfully gotten them working together except ALL together. When I do the final bundle, I get an error where the SD card is not recognized. I believe the conflict is between the energyShield and the DMX shield because when I add the DMXsimple.h library in an include statement to a working build that has all the other components working, I can get the same error:

When I add the NS_energyShield Include statement, I get the following monitor output and no sound:

Hello simple_mp3_button.ino Adafruit VS1053 Simple Test with button VS1053 found XYXVtto play Setup complete. all lights set to 0 Starting buttonState =0 Read buttonState =0 Set buttonState =0 Ready to play . . . . . . . . . . . . . . Now Playing DONE Playing starting DMX Starting buttonState =0 Read buttonState =0 Set buttonState =0 Ready to play . . . . . . . . . . . . .

When I add the two statements: NS_energyShield2 es2; //and es2.begin(); // in setup,

The setup doesn't recognize the SD card.

Hello simple_mp3_button.ino Afrfruit VS1053 Simple Test with button VS1053 found SD failed, or not present

The way I'm getting it to work right now is to leave out the energyShield library and, I guess, just use it as a dumb battery that has no controls. That's actually okay for this project as I don't need the clock and the other functions right now. But I would like to understand what I might be doing wrong. Here's the prototype code:

`/**** This is a routine to run the lights and sound for the "One-Guitar Show" Miss Isabella Rainsong and Her Traveling Companion by embedding an arduino inside the RainSong guitar used in the performance and triggering the lighting and audio cues with a button hidden on the guitar. The button triggers DMX cues and MP3 audio that is wirelessly sent from the guitar to the light rig and the PA system respectively.

The show and this code have been written and performed by Ross D. Martin ross@acmimimi.org mailto:ross@acmimimi.org www.MissRainsong.com http://www.MissRainsong.com

Hardware:

Wiring:

Software based on:

Overview:

DMX Assignments: Back Wall Stage Right Back Stage Left Back


           |ch51-53|---same----|ch51-53|
            -------             -------
               6                   5

4 3 Blacklight 2 1


ch41-43 ch31-33 ch01-03 ch21-23 ch11-13
                     Front
                    AUDIENCE

Each light has seven DMX channels, but this setup uses only three: Red, Green, Blue -- with each channel accepting a range of 0 (off) to 255 (100% on). Lights are set to the first channel they are assigned (1, 8, 15, etc.) and set to 3-Ch. Blacklight has four channels operating four sets of dimmable blacklights.

MP3 Files Named rainsngX.mp3 X = sequential digit

Thanks to Brian Donnelly for introducing me to Arduino. Thanks to the many open source folks to posted questions and answers and videos and diagrams to make this technology dumpster dive adventure possible. This project was created by Ross Martin between June 10, 2019 and whenever I decide it's finished-ish.

Many Bothans died to bring us this automation...

***/

//SET-UP

// DmxSimple - Version: Latest // include SPI, MP3 and SD libraries // Adafruit VS1053 Library - Version: Latest // energyShield libraries

include

include

include

include

//#include //#include

// See http://arduino.cc/en/Reference/SPI "Connections"

define BREAKOUT_RESET 9 // VS1053 reset pin (output)

define BREAKOUT_CS 10 // VS1053 chip select pin (output)

define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)

// These are the pins used for the music maker shield

define SHIELD_RESET -1 // VS1053 reset pin (unused!)

define SHIELD_CS 7 // VS1053 chip select pin (output)

define SHIELD_DCS 6 // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield

define CARDCS 4 // Card chip select pin

// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt

define DREQ 3 // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer = // create shield-example object! Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

//NS_energyShield2 es2;

// constants won't change. They're used here to set pin numbers: const int buttonPin = 8; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin

// variables will change: String sceneString; String musicFile;

int buttonState = 0; // variable for reading the pushbutton status int currentScene = 4; // Marks the current scene. Used to build the MP3 filename call int sceneJump = 1; // for moving between scenes with button (can go forward or backward) int brightness; // Current brightness of the light being set int rbright; int gbright; int bbright; int blbright; int fullbright; int halfbright; int dimbright;

void setup() { //es2.begin(); // Initializes the energyShield 2 /* The most common pin for DMX output is pin 3, which DmxSimple uses by default. If you need to change that, do it here. USING 10 to avoid compatibility issues with MP3 Player./ DmxSimple.usePin(10); / DMX devices typically need to receive a complete set of channels even if you only need to adjust the first channel. You can easily change the number of channels sent here. If you don't do this, DmxSimple will set the maximum channel number to the * highest channel you DmxSimple.write() to. / DmxSimple.maxChannel(100); musicPlayer.setVolume(20, 20); //PRE-CURTAIN Serial.begin(9600); Serial.println(F("Hello")); Serial.println("simple_mp3_button.ino Adafruit VS1053 Simple Test with button"); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); if (! musicPlayer.begin()) { // initialise the music player Serial.println(F("Couldn't find VS1053, do you have the right pins defined?")); while (1); } Serial.println(F("VS1053 found"));

if (!SD.begin(CARDCS)) { Serial.println(F("SD failed, or not present")); while (1); // don't do anything more }

// list files //printDirectory(SD.open("/"), 0);

// Set volume for left, right channels. lower numbers == louder volume! musicPlayer.setVolume(20,20);

// Timer interrupts are not suggested, better to use DREQ interrupt! //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

// If DREQ is on an interrupt pin (on uno, #2 https://github.com/nightshade-electronics/energyShield2/issues/2 or #3 https://github.com/nightshade-electronics/energyShield2/pull/3 ) we can do background // audio playing musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int

/ // Play another file in the background, REQUIRES interrupts! Serial.println(F("Playing track 002")); musicPlayer.startPlayingFile("/track002.mp3");/ //nextScene(sceneJump); Serial.print(F("ready to play ")); Serial.println(musicFile);

Serial.println("Setup complete.");

brightness = 0; dimbright = 10; halfbright = 125; fullbright = 255;

// Reset lights to off //Light 1 (front, stage far L) DmxSimple.write(1, brightness); //red DmxSimple.write(2, brightness); //green DmxSimple.write(3, brightness); //blue //Light 2 (front, stage mid L) DmxSimple.write(11, brightness); //red DmxSimple.write(12, brightness); //green DmxSimple.write(13, brightness); //blue //Light 3 (front, stage mid R) DmxSimple.write(21, brightness); //red DmxSimple.write(22, brightness); //green DmxSimple.write(23, brightness); //blue //Light 4 (front, stage far R) DmxSimple.write(31, brightness); //red DmxSimple.write(32, brightness); //green DmxSimple.write(33, brightness); //blue //Light 5 (rear, stage L) DmxSimple.write(41, brightness); //red DmxSimple.write(42, brightness); //green DmxSimple.write(43, brightness); //blue //Light 6 (rear, stage R) DmxSimple.write(51, brightness); //red DmxSimple.write(52, brightness); //green DmxSimple.write(53, brightness); //blue //Blacklight DmxSimple.write(1, brightness); //Blacklight DmxSimple.write(2, brightness); DmxSimple.write(3, brightness); DmxSimple.write(4, brightness); delay(300);

Serial.println("all lights set to 0"); //Blacklight DmxSimple.write(1, 255); //Blacklight DmxSimple.write(2, 255); DmxSimple.write(3, 255); DmxSimple.write(4, 255); delay(300); DmxSimple.write(1, brightness); //Blacklight DmxSimple.write(2, brightness); DmxSimple.write(3, brightness); DmxSimple.write(4, brightness);

} //SCENE 1 -- Curtain up! void loop() { // waiting for button push / Serial.print("Starting buttonState ="); Serial.println(buttonState); buttonState = digitalRead(buttonPin); Serial.print("Read buttonState ="); Serial.println(buttonState); buttonState = LOW; Serial.print("Set buttonState ="); Serial.println(buttonState); Serial.print(F("Ready to play ")); Serial.println(musicFile); / buttonState = LOW; // check if the pushbutton is pressed. If it is, the buttonState is HIGH: Serial.println("waiting for button"); while (buttonState == LOW) { delay(5); buttonState = digitalRead(buttonPin); //Serial.print(F(". ")); } // check for reset request (1 second button push). If yes, start scenes from the beginning delay(200); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { currentScene = 6; }

nextScene(sceneJump); // Start playing current file Serial.println(); Serial.print(F("Now Playing ")); Serial.println(musicFile); musicPlayer.startPlayingFile(musicFile.c_str());

delay(100);

Serial.print(F("DONE Playing ")); Serial.println(musicFile); digitalWrite(ledPin, HIGH); brightness = 0; dimbright = 10; halfbright = 125; fullbright = 255; // if (! musicPlayer.begin()) { // initialise the music player // Serial.println(F("Couldn't find VS1053, do you have the right pins defined?")); // while (1); // } // Serial.println(F("VS1053 found"));

/* if (!SD.begin(CARDCS)) { Serial.println(F("SD failed, or not present")); while (1); // don't do anything more }

// list files // printDirectory(SD.open("/"), 0);

// Set volume for left, right channels. lower numbers == louder volume! musicPlayer.setVolume(20, 20);

// Timer interrupts are not suggested, better to use DREQ interrupt! //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

// If DREQ is on an interrupt pin (on uno, #2 https://github.com/nightshade-electronics/energyShield2/issues/2 or #3 https://github.com/nightshade-electronics/energyShield2/pull/3 ) we can do background // audio playing musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int

// Play one file, don't return until complete Serial.println(F("Playing 1"));

// musicPlayer.playFullFile("rainsng1.mp3"); if (! musicPlayer.startPlayingFile("/rainsng1.mp3")) { Serial.println("Could not open file rainsng11.mp3"); while (1); } Serial.println(F("Started playing"));

while (musicPlayer.playingMusic) { // file is now playing in the 'background' so now's a good time // to do something else like handling LEDs or buttons :) Serial.print("."); delay(1000);

Serial.println("still playing music");

Serial.println("Playing 1"); // musicPlayer.startPlayingFile("/rainsng1.mp3"); // musicPlayer.playFullFile("/rainsng1.mp3");*/ Serial.println(F("starting DMX")); brightness = 0; while(brightness <=255) { //Light 1 (front, stage far L) DmxSimple.write(1, brightness); //red DmxSimple.write(2, brightness); //green DmxSimple.write(3, brightness); //blue //Light 2 (front, stage mid L) DmxSimple.write(11, brightness); //red DmxSimple.write(12, brightness); //green DmxSimple.write(13, brightness); //blue //Light 3 (front, stage mid R) DmxSimple.write(21, brightness); //red DmxSimple.write(22, brightness); //green DmxSimple.write(23, brightness); //blue //Light 4 (front, stage far R) DmxSimple.write(31, brightness); //red DmxSimple.write(32, brightness); //green DmxSimple.write(33, brightness); //blue //Light 5 (rear, stage L) DmxSimple.write(41, brightness); //red DmxSimple.write(42, brightness); //green DmxSimple.write(43, brightness); //blue //Light 6 (rear, stage R) DmxSimple.write(51, brightness); //red DmxSimple.write(52, brightness); //green DmxSimple.write(53, brightness); //blue //Blacklight DmxSimple.write(1, brightness); //Blacklight DmxSimple.write(2, brightness); DmxSimple.write(3, brightness); DmxSimple.write(4, brightness); delay(10); brightness++; } delay(2000); while(brightness >=0) { //Light 1 (front, stage far L) //DmxSimple.write(1, brightness); //red DmxSimple.write(2, brightness); //green DmxSimple.write(3, brightness); //blue //Light 2 (front, stage mid L) DmxSimple.write(11, brightness); //red //DmxSimple.write(12, brightness); //green DmxSimple.write(13, brightness); //blue //Light 3 (front, stage mid R) DmxSimple.write(21, brightness); //red DmxSimple.write(22, brightness); //green //DmxSimple.write(23, brightness); //blue //Light 4 (front, stage far R) DmxSimple.write(31, brightness); //red DmxSimple.write(32, brightness); //green DmxSimple.write(33, brightness); //blue //Light 5 (rear, stage L) //DmxSimple.write(41, brightness); //red DmxSimple.write(42, brightness); //green //DmxSimple.write(43, brightness); //blue //Light 6 (rear, stage R) //DmxSimple.write(51, brightness); //red //DmxSimple.write(52, brightness); //green DmxSimple.write(53, brightness); //blue //Blacklight DmxSimple.write(1, brightness); //Blacklight DmxSimple.write(2, brightness); DmxSimple.write(3, brightness); DmxSimple.write(4, brightness); delay(10); brightness--; } brightness = 0;

/* if (! musicPlayer.begin()) { // initialise the music player Serial.println(F("Couldn't find VS1053, do you have the right pins defined?")); while (1); } Serial.println(F("VS1053 found"));

if (!SD.begin(CARDCS)) { Serial.println(F("SD failed, or not present")); while (1); // don't do anything more }

// list files //printDirectory(SD.open("/"), 0);

// Set volume for left, right channels. lower numbers == louder volume! musicPlayer.setVolume(20, 20);

// Timer interrupts are not suggested, better to use DREQ interrupt! //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

// If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background // audio playing musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int

// Play one file, don't return until complete Serial.println(F("Playing 1")); musicPlayer.startPlayingFile("/rainsng1.mp3");*/

//DMX lighting signal while (brightness <= 254) { brightness++; DmxSimple.write(1, 255); //red DmxSimple.write(2, 0); //green DmxSimple.write(3, 25); //blue DmxSimple.write(5, 50); //Strobe DmxSimple.write(7, brightness); //brightness delay(20); }

while (musicPlayer.playingMusic) { Serial.print(". "); delay(100); } Serial.println("ending DMX"); digitalWrite(ledPin, HIGH); delay(2000); digitalWrite(ledPin, LOW);

}

/// File listing helper void printDirectory(File dir, int numTabs) { while (true) {

File entry = dir.openNextFile(); if (! entry) { // no more files //Serial.println("nomorefiles"); break; } for (uint8_t i = 0; i < numTabs; i++) { Serial.print('\t'); } Serial.print(entry.name()); if (entry.isDirectory()) { Serial.println("/"); printDirectory(entry, numTabs + 1); } else { // files have sizes, directories do not Serial.print("\t\t"); Serial.println(entry.size(), DEC); } entry.close();

} }

//nextScene: sets up for the following scene by: // setting buttonState to LOW // setting currentScene to ++ // setting mp3 file to next file void nextScene(int jump) { buttonState = 0; currentScene = currentScene + jump; sceneString = String(currentScene); musicFile = String("/T" + String(sceneString) + ".mp3"); } //Text from sources: /*** This is an example for the Adafruit VS1053 Codec Breakout

Designed specifically to work with the Adafruit VS1053 Codec Breakout ----> https://www.adafruit.com/products/1381

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution ****/

/ Welcome to DmxSimple. This library allows you to control DMX stage and architectural lighting and visual effects easily from Arduino. DmxSimple is compatible with the Tinker.it! DMX shield and all known DIY Arduino DMX control circuits. DmxSimple is available from: http://code.google.com/p/tinkerit/ Help and support: http://groups.google.com/group/dmxsimple /

/* To use DmxSimple, you will need the following line. Arduino will * auto-insert it if you select Sketch > Import Library > DmxSimple. /`

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nightshade-electronics/energyShield2/issues/4?email_source=notifications&email_token=ACAKL3FFBVXAIS6MMQRJR5LP46SKNA5CNFSM4H4K56O2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4OR2YQ , or mute the thread https://github.com/notifications/unsubscribe-auth/ACAKL3HVLI4MHET4LHZYQ53P46SKNANCNFSM4H4K56OQ . https://github.com/notifications/beacon/ACAKL3FJSHR47JA7MSTNSODP46SKNA5CNFSM4H4K56O2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4OR2YQ.gif

nitramor commented 5 years ago

Thank you, Aaron! I had already changed the LED setting (and meant to include a pin map, which is herehttps://docs.google.com/document/d/1h2rISHF0jjJvBB1pWmf98yqUberVeRSF_i84RpF3Uyo/edit?usp=sharing). I have been in Arduino hell these last few days trying to isolate a sudden failure (with a summer cold to boot). I think it was all due to shoddy pin soldering, but I’m just not sure. Was up until 4am (with a cold) determined to get it working again. Fortunately, I finally got it back in working order and it seems to be stable now.

I do think it’s the SDA/SCL conflict that is causing the issue. Since I don’t really need any of the functions of the pro currently (initially thought I might use the clock, but I don’t think I need it now), I think I can get away with just using it as a dumb battery. Is that the case? Even for that function, it is really useful to have the battery as a shield. I bought a second “basic” energyShield for a backup for the show (and will test it, of course).

Will post a video soon! Thanks again for all your help!

Ross www.MissRainsong.comhttp://www.MissRainsong.com

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/nightshade-electronics/energyShield2/issues/4?email_source=notifications&email_token=AJZPM5U7ZQNBKA3BBWXSKCTP5IEU5A5CNFSM4H4K56O2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY6G3TA#issuecomment-507276748, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJZPM5UTEVSI7POSMBXHFKTP5IEU5ANCNFSM4H4K56OQ.

aliebold commented 5 years ago

Hi Ross,

You’re welcome.

I’m glad you got that sorted out. Yes, the eS2 Pro will work just fine without any communication from the processor. In your application, I would probably be most interested in using the fuel gauge to display a low battery warning with the onboard LED or some other indicator.

I look forward to the video!

Best regards,

Aaron Liebold

NightShade Electronics

Phone: 321-473-4490 Ext. 103

Email: mailto:aliebold@ns-electric.com aliebold@ns-electric.com

Website: http://ns-electric.com/ http://ns-electric.com

Confidential Notice: The contents of this email and its attachments are the sole property of Liebold Technologies, LLC. No portion of this e-mail and/or correspondence its attachment(s) may be reproduced without written consent of Liebold Technologies, LLC. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. The information contained in this message and or attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient or believe that you may have received this document in error, please notify the sender and delete this e-mail and any attachments immediately.

From: Ross Martin notifications@github.com Sent: Thursday, July 4, 2019 4:32 PM To: nightshade-electronics/energyShield2 energyShield2@noreply.github.com Cc: Aaron Liebold aliebold@ns-electric.com; Comment comment@noreply.github.com Subject: Re: [nightshade-electronics/energyShield2] Compatibility between energyShield2, Tinker DMX, and Adafruit MP3 Music Maker (#4)

Thank you, Aaron! I had already changed the LED setting (and meant to include a pin map, which is herehttps://docs.google.com/document/d/1h2rISHF0jjJvBB1pWmf98yqUberVeRSF_i84RpF3Uyo/edit?usp=sharing). I have been in Arduino hell these last few days trying to isolate a sudden failure (with a summer cold to boot). I think it was all due to shoddy pin soldering, but I’m just not sure. Was up until 4am (with a cold) determined to get it working again. Fortunately, I finally got it back in working order and it seems to be stable now.

I do think it’s the SDA/SCL conflict that is causing the issue. Since I don’t really need any of the functions of the pro currently (initially thought I might use the clock, but I don’t think I need it now), I think I can get away with just using it as a dumb battery. Is that the case? Even for that function, it is really useful to have the battery as a shield. I bought a second “basic” energyShield for a backup for the show (and will test it, of course).

Will post a video soon! Thanks again for all your help!

Ross www.MissRainsong.com http://www.MissRainsong.com%3chttp:/www.MissRainsong.com http://www.MissRainsong.com

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<https://github.com/nightshade-electronics/energyShield2/issues/4?email_source=notifications https://github.com/nightshade-electronics/energyShield2/issues/4?email_source=notifications&email_token=AJZPM5U7ZQNBKA3BBWXSKCTP5IEU5A5CNFSM4H4K56O2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY6G3TA#issuecomment-507276748 &email_token=AJZPM5U7ZQNBKA3BBWXSKCTP5IEU5A5CNFSM4H4K56O2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY6G3TA#issuecomment-507276748>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJZPM5UTEVSI7POSMBXHFKTP5IEU5ANCNFSM4H4K56OQ.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nightshade-electronics/energyShield2/issues/4?email_source=notifications&email_token=ACAKL3FQ2HHCJS2HGQQQF5LP5ZM4DA5CNFSM4H4K56O2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZIDAEY#issuecomment-508571667 , or mute the thread https://github.com/notifications/unsubscribe-auth/ACAKL3F4UUYDWWVBG4DVBSDP5ZM4DANCNFSM4H4K56OQ . https://github.com/notifications/beacon/ACAKL3EMG3KM5XMJAZDV7SDP5ZM4DA5CNFSM4H4K56O2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZIDAEY.gif