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...
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");
}
}
}