I'm stuck

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_bill
 
Posts: 85045
Joined: Sat Feb 07, 2009 10:11 am

Re: I'm stuck

Post by adafruit_support_bill »

Let's try testing the midi function alone - without the color sensor. The code below is the midi example from the library - I modified it to use pin 10 for the serial communication as you have it wired on the Flora:

Code: Select all

/*************************************************** 
  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
 ****************************************************/

#include <SoftwareSerial.h>

// define the pins used
#define VS1053_RX  2 // This is the pin that connects to the RX pin on VS1053
#define VS1053_RESET 9 // This is the pin that connects to the RESET pin on VS1053
// Don't forget to connect the GPIO #0 to GROUND and GPIO #1 pin to 3.3V

// See http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf Pg 31
#define VS1053_BANK_DEFAULT 0x00
#define VS1053_BANK_DRUMS1 0x78
#define VS1053_BANK_DRUMS2 0x7F
#define VS1053_BANK_MELODY 0x79

// See http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf Pg 32 for more!
#define VS1053_GM1_OCARINA 80

#define MIDI_NOTE_ON  0x90
#define MIDI_NOTE_OFF 0x80
#define MIDI_CHAN_MSG 0xB0
#define MIDI_CHAN_BANK 0x00
#define MIDI_CHAN_VOLUME 0x07
#define MIDI_CHAN_PROGRAM 0xC0


SoftwareSerial VS1053_MIDI(0, 10); // TX only, do not use the 'rx' side
// on a Mega/Leonardo you may have to change the pin to one that 
// software serial support uses OR use a hardware serial port!

void setup() {
  Serial.begin(9600);
  Serial.println("VS1053 MIDI test");
  
  VS1053_MIDI.begin(31250); // MIDI uses a 'strange baud rate'
  
  pinMode(VS1053_RESET, OUTPUT);
  digitalWrite(VS1053_RESET, LOW);
  delay(10);
  digitalWrite(VS1053_RESET, HIGH);
  delay(10);
  
  midiSetChannelBank(0, VS1053_BANK_MELODY);
  midiSetInstrument(0, VS1053_GM1_OCARINA);
  midiSetChannelVolume(0, 127);
}

void loop() {  
  for (uint8_t i=60; i<69; i++) {
    midiNoteOn(0, i, 127);
    delay(100);
    midiNoteOff(0, i, 127);
  }
  
  delay(1000);
}

void midiSetInstrument(uint8_t chan, uint8_t inst) {
  if (chan > 15) return;
  inst --; // page 32 has instruments starting with 1 not 0 :(
  if (inst > 127) return;
  
  VS1053_MIDI.write(MIDI_CHAN_PROGRAM | chan);  
  VS1053_MIDI.write(inst);
}


void midiSetChannelVolume(uint8_t chan, uint8_t vol) {
  if (chan > 15) return;
  if (vol > 127) return;
  
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write(MIDI_CHAN_VOLUME);
  VS1053_MIDI.write(vol);
}

void midiSetChannelBank(uint8_t chan, uint8_t bank) {
  if (chan > 15) return;
  if (bank > 127) return;
  
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write((uint8_t)MIDI_CHAN_BANK);
  VS1053_MIDI.write(bank);
}

void midiNoteOn(uint8_t chan, uint8_t n, uint8_t vel) {
  if (chan > 15) return;
  if (n > 127) return;
  if (vel > 127) return;
  
  VS1053_MIDI.write(MIDI_NOTE_ON);
  VS1053_MIDI.write(n);
  VS1053_MIDI.write(vel);
}

void midiNoteOff(uint8_t chan, uint8_t n, uint8_t vel) {
  if (chan > 15) return;
  if (n > 127) return;
  if (vel > 127) return;
  
  VS1053_MIDI.write(MIDI_NOTE_OFF | chan);
  VS1053_MIDI.write(n);
  VS1053_MIDI.write(vel);
}
  

talymo
 
Posts: 25
Joined: Wed Aug 14, 2013 9:09 am

Re: I'm stuck

Post by talymo »

I will try this when I get home.

I disconnected everything and hooked all my parts up to a breadboard so I can test things a little more flexibly and I still got only clicks from the speaker when I interacted with the color sensor, no musical notes.

So, I went ahead and tested the functionality with an Uno and a piezo speaker and I got the sensor unit to interact with the Uno and play a tone through the piezo speaker.

This kind of makes me wonder if there is something wrong with the midi board.

If I have to, I will just keep rolling with the Uno and modify everything to run off that instead of the midi board.

I am at work right now and can't run any tests on the midi board right at the moment, but I will definitely try when I get home tonight.

I know I ran a similar test on the Midi a couple days ago and got nothing, so here's to hoping that this works because I really want this project to work. :)

talymo
 
Posts: 25
Joined: Wed Aug 14, 2013 9:09 am

Re: I'm stuck

Post by talymo »

adafruit_support_bill wrote:Let's try testing the midi function alone - without the color sensor. The code below is the midi example from the library - I modified it to use pin 10 for the serial communication as you have it wired on the Flora:

Code: Select all

/*************************************************** 
  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
 ****************************************************/

#include <SoftwareSerial.h>

// define the pins used
#define VS1053_RX  2 // This is the pin that connects to the RX pin on VS1053
#define VS1053_RESET 9 // This is the pin that connects to the RESET pin on VS1053
// Don't forget to connect the GPIO #0 to GROUND and GPIO #1 pin to 3.3V

// See http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf Pg 31
#define VS1053_BANK_DEFAULT 0x00
#define VS1053_BANK_DRUMS1 0x78
#define VS1053_BANK_DRUMS2 0x7F
#define VS1053_BANK_MELODY 0x79

// See http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf Pg 32 for more!
#define VS1053_GM1_OCARINA 80

#define MIDI_NOTE_ON  0x90
#define MIDI_NOTE_OFF 0x80
#define MIDI_CHAN_MSG 0xB0
#define MIDI_CHAN_BANK 0x00
#define MIDI_CHAN_VOLUME 0x07
#define MIDI_CHAN_PROGRAM 0xC0


SoftwareSerial VS1053_MIDI(0, 10); // TX only, do not use the 'rx' side
// on a Mega/Leonardo you may have to change the pin to one that 
// software serial support uses OR use a hardware serial port!

void setup() {
  Serial.begin(9600);
  Serial.println("VS1053 MIDI test");
  
  VS1053_MIDI.begin(31250); // MIDI uses a 'strange baud rate'
  
  pinMode(VS1053_RESET, OUTPUT);
  digitalWrite(VS1053_RESET, LOW);
  delay(10);
  digitalWrite(VS1053_RESET, HIGH);
  delay(10);
  
  midiSetChannelBank(0, VS1053_BANK_MELODY);
  midiSetInstrument(0, VS1053_GM1_OCARINA);
  midiSetChannelVolume(0, 127);
}

void loop() {  
  for (uint8_t i=60; i<69; i++) {
    midiNoteOn(0, i, 127);
    delay(100);
    midiNoteOff(0, i, 127);
  }
  
  delay(1000);
}

void midiSetInstrument(uint8_t chan, uint8_t inst) {
  if (chan > 15) return;
  inst --; // page 32 has instruments starting with 1 not 0 :(
  if (inst > 127) return;
  
  VS1053_MIDI.write(MIDI_CHAN_PROGRAM | chan);  
  VS1053_MIDI.write(inst);
}


void midiSetChannelVolume(uint8_t chan, uint8_t vol) {
  if (chan > 15) return;
  if (vol > 127) return;
  
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write(MIDI_CHAN_VOLUME);
  VS1053_MIDI.write(vol);
}

void midiSetChannelBank(uint8_t chan, uint8_t bank) {
  if (chan > 15) return;
  if (bank > 127) return;
  
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write((uint8_t)MIDI_CHAN_BANK);
  VS1053_MIDI.write(bank);
}

void midiNoteOn(uint8_t chan, uint8_t n, uint8_t vel) {
  if (chan > 15) return;
  if (n > 127) return;
  if (vel > 127) return;
  
  VS1053_MIDI.write(MIDI_NOTE_ON);
  VS1053_MIDI.write(n);
  VS1053_MIDI.write(vel);
}

void midiNoteOff(uint8_t chan, uint8_t n, uint8_t vel) {
  if (chan > 15) return;
  if (n > 127) return;
  if (vel > 127) return;
  
  VS1053_MIDI.write(MIDI_NOTE_OFF | chan);
  VS1053_MIDI.write(n);
  VS1053_MIDI.write(vel);
}
  
Ok, got the code test uploaded, everything hooked up and all I get is a rapid series of very faint clicks from the speakers. It sounds like 8 clicks a slight pause then 8 clicks, looping over and over again.

both my color sensor and my neopixel is activated and lit up. The neopixel is a green color.

talymo
 
Posts: 25
Joined: Wed Aug 14, 2013 9:09 am

Re: I'm stuck

Post by talymo »

Alright, I hooked up the vs1053 board like this example shows...

http://learn.adafruit.com/adafruit-vs10 ... onnections

I still get nothing.

I honestly think it is something to do with the board now.

talymo
 
Posts: 25
Joined: Wed Aug 14, 2013 9:09 am

Re: I'm stuck

Post by talymo »

uggghhhhh... I'm starting to get so frustrated. :(

I don't know what is wrong with the VS1053 board but no matter what kind of test I try to run on it, nothing comes out. Just static and clicks.

You think the board is damaged? Should I order a new one?

I don't want to order a new one and then the same thing happen though.

What do you suggest?

User avatar
adafruit_support_bill
 
Posts: 85045
Joined: Sat Feb 07, 2009 10:11 am

Re: I'm stuck

Post by adafruit_support_bill »

Contact support@adafruit.com with a link to this thread for a replacement VS1053 board.

talymo
 
Posts: 25
Joined: Wed Aug 14, 2013 9:09 am

Re: I'm stuck

Post by talymo »

Do you guys plan to get this board back in stock. It says 5-10 business days on the website but it has been more than that...

User avatar
ladysputnick
 
Posts: 14
Joined: Wed Oct 22, 2014 8:38 pm

Re: I'm stuck

Post by ladysputnick »

Omg the exact same thing happened to me! I'm stuck exactly there. This project is due on friday, should I really just order another board? Is that what was wrong with your project?

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

Re: I'm stuck

Post by Franklin97355 »

This project is due on friday, should I really just order another board?
You could start your own thread and post the details of what you have and what you've tried along with pictures and diagrams but if you need it by Friday I would order another just to be on the safe side. We will do all we can to help you with your problem. Let us know

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

Return to “General Project help”