Music Maker shield alternate universe

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
zenSutherland
 
Posts: 42
Joined: Fri Jul 27, 2018 11:50 am

Music Maker shield alternate universe

Post by zenSutherland »

WTHeck!
Ok, i'm not a novice, but not a superuser yet, but I'm completely flummoxed (love that word) with what seems like bizarro world where 2=32000. I'm currently working with a working Arduino Uno and the Music Maker shield on top. I have reset my computer, unplugged the board and even left the house to get away from it, but opening it all back up get the same thing.

The board and shield (untouched) run previous programs fine. I've seen some strange results when pushing the limits of program storage, but this uses only 41%.

I've obviously dorked something up in the setup or before that, but I'd sure like someone to point me in a direction to test...
Here's the output of a run
Here's the output of a run
arduino output.jpeg (37.94 KiB) Viewed 92 times

Code: Select all

/***************************************************

 ****************************************************/

// include SPI, MP3 and SD libraries for MUSIC
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif

// 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
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

// Neopixel definitions
#define LEDPIN            10
#define NUMPIXELS      8
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, LEDPIN, NEO_GRB + NEO_KHZ800);
int delayval = 100; // delay for half a second

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

// include for distance
#include <NewPing.h>
#define TRIGGER_PIN 9
#define ECHO_PIN 8
#define MAX_DISTANCE 200

// buttons
#define frontButton 1
#define backButton 2

unsigned long timerStart;
unsigned long timerCurrent;

const unsigned long period = 10000;  //the value is a number of milliseconds, ie 10 seconds


void preferenceSet();
int waitForButton();

// NewPing setup of pins and maximum distance
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
////

// ** FILE ARRAYS **
char* closefar[] = {"closfar1.mp3", "closfar2.mp3", "closfar3.mp3"};
char* closer[] = {"closer1.mp3", "closer2.mp3"};

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

  // Beginning Error Codes ************************ Delete when done *************
  Serial.println("Adafruit VS1053 Library Test");
  // initialise the music player
  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"));
  musicPlayer.sineTest(0x44, 300);    // Make a tone to indicate VS1053 is working
  if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }
  Serial.println("SD OK!");

  // END Error Codes ********************************************************

  //  pinMode(frontButton, INPUT_PULLUP);
  //  pinMode(backButton, INPUT_PULLUP);

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

  /***** Two interrupt options! *******/
  // This option uses timer0, this means timer1 & t2 are not required
  // (so you can use 'em for Servos, etc) BUT millis() can lose time
  // since we're hitchhiking on top of the millis() tracker
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT);

  // This option uses a pin interrupt. No timers required! But DREQ
  // must be on an interrupt pin. For Uno/Duemilanove/Diecimilla
  // that's Digital #2 or #3
  // See http://arduino.cc/en/Reference/attachInterrupt for other pins
  // *** This method is preferred

  if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT))
    Serial.println(F("DREQ pin is not an interrupt pin"));

  // BELOW is when just playing the mp3 without interupt
  //  musicPlayer.playFullFile("closer1.mp3");
  //
  pixels.begin(); // This initializes the NeoPixel library.

  musicPlayer.playFullFile("poweron.mp3");
}

void loop() {
  // put your main code here, to run repeatedly:
      Serial.println(" ** Start of Code **");
  while (1) {
int y = 2;
    Serial.print("y = ");
    Serial.println(y);
    if (y = 1) Serial.println("Y equals 1");
    if (y = 2) Serial.println("Y equals 2");
    if (y = 3) Serial.println("Y equals 3");
    if (y = 32000) {
      Serial.println("Y equals 32000");
    }
  }
}

[The extension ino has been deactivated and can no longer be displayed.]

arduino compile.jpeg
arduino compile.jpeg (110.96 KiB) Viewed 92 times
Last edited by zenSutherland on Sun Oct 21, 2018 4:57 pm, edited 3 times in total.

User avatar
zenSutherland
 
Posts: 42
Joined: Fri Jul 27, 2018 11:50 am

Re: Music Maker shield alternate universe

Post by zenSutherland »

It has to be my arduino board, i guess...

I've cleared out the entire pre-setup and setup parts and still get

Code: Select all

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Start of Code");
  int y = 2;
  y = y - 1;
  Serial.print("y = ");
  Serial.println(y);
  if (y = 1) Serial.println("Y equals 1");
  if (y = 2) Serial.println("Y equals 2");
  int a = 7;
  if (a = 1) {
    Serial.println("a = 7");
  }
}
and still get:

Code: Select all

Start of Code
y = 1
Y equals 1
Y equals 2
a = 7
Start of Code
y = 1
Y equals 1
Y equals 2
a = 7
Start of Code
y = 1
Y equals 1
Y equals 2
a = 7
Start of Code
y = 1
Y equals 1
Y equals 2
a = 7
Sketch uses 1662 bytes (5%) of program storage space.

It's only thing i can figure and i don't have another Arduino board to swap out to test this tonight...

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Music Maker shield alternate universe

Post by Franklin97355 »

You have equals (=) and is equal to (==) mixed up in your code. if (y = 1) Serial.println("Y equals 1"); will set y to 1 and do the serial print

User avatar
zenSutherland
 
Posts: 42
Joined: Fri Jul 27, 2018 11:50 am

Re: Music Maker shield alternate universe

Post by zenSutherland »

aaaaannnnddd, there!

Once again i've proved i'm an idiot. (and my early BASIC programming shining thru for me again!)

Thank you thank you!
You've earned my undying (and silly) friendship!
zen

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”