Le forum a migré vers l'adresse suivante:

Forum

Masquer ce message

Simple-Duino Forum Index



Programmation Carte Adafruit Wave Sound


 
Post new topic   Reply to topic    Simple-Duino Forum Index -> Arduino & Électronique -> Questions
Previous topic :: Next topic  
Author Message
Ranjy
Débutant

Offline

Joined: 17 Apr 2014
Posts: 7
Masculin
Niveau d'éléctronique: Pro

PostPosted: Tue 3 Jun - 14:23 (2014)    Post subject: Programmation Carte Adafruit Wave Sound Reply with quote

PublicitéSupprimer les publicités ?
Bonjour,

J'ai récemment acquis la carte Adafruit Wave Sound v1.1. Je l'ai donc placé sur une carte Arduino Uno Rev3.

Ma carte SD contiendra 19 sons.
Lorsque je voudrai envoyer n'importe quel son, ma carte Arduino Mega enverra un message. Par exemple : lorsque ma Mega enverra à la Uno "004", la Uno devra lancer le message 004.

        Wire.beginTransmission(4);//Début de communication UNO
        Wire.write('001'); //Lancer message #1
        Wire.endTransmission(); //Fin de transmission

Pour envoyer des messages de ma Mega et les recevoir avec la Uno, je pense avoir le programme qui fonctionne mais mon problème est celui-ci :

Je ne sais pas quel programme je dois entrer dans ma Uno, il y en a quelques uns et ceux que je test ne fonctionnent pas.

Si l'un d'entre vous à déjà utilisé ces programmes ou si vous avez une idée, n'hésitez pas à m'en faire part car je suis complètement perdu.



La partie concernant uniquement la lecture du message est ci-dessous : (j'imagine qu'il doit manquer beaucoup de lignes de code mais je ne sais vraiment pas ce que je dois y mettre de plus, les tutos sur le site ne m'aide pas du tout.)

// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  while (wave.isplaying) {
  // do nothing while its playing
  }
  // now its done playing
}

void playfile(char *name) {
  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); Serial.print(name); return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); return;
  }
 
  // ok time to play! start playback
  wave.play();
}


Merci d'avance.

Benjamin.
Back to top
Admin
Fondateur

Offline

Joined: 12 Apr 2012
Posts: 860
Masculin
Niveau d'éléctronique: Pro

PostPosted: Wed 4 Jun - 10:08 (2014)    Post subject: Programmation Carte Adafruit Wave Sound Reply with quote

Tu ne rentres que ce bout de script dans ton Arduino ?? Normalement, avec seulement ça, ça doit pas compiler...
Il nous faut le programme en entier pour pouvoir l'analyser
____________________________
http://simple-duino.com
Back to top
Ranjy
Débutant

Offline

Joined: 17 Apr 2014
Posts: 7
Masculin
Niveau d'éléctronique: Pro

PostPosted: Wed 4 Jun - 11:42 (2014)    Post subject: Programmation Carte Adafruit Wave Sound Reply with quote

#include <Wire.h>
#include <WaveHC.h>


const int SDAUnopin = 5;//voie SDA vers UNO
const int SCLUnopin = 4;//voie SCL vers UNO
char name;
void setup()
{
  Wire.begin(5);
  Wire.onReceive(receiveEvent);
}

void loop()
{
}

void receiveEvent()
{
  while(Wire.available())
  {
    
    int son = Wire.read();
   
    switch(son)
    {
      case 1:
        name = "001";
      break;
      case 2:
        name = "002";
      break;
      case 3:
        name = "003";
      break;
      case 4:
        name = "004";
      break;
      case 5:
        name = "005";
      break;
      case 6:
        name = "006";
      break;
      case 7:
        name = "007";
      break;
      case 8:
        name = "008";
      break;
      case 9:
        name = "009";
      break;
      case 10:
        name = "010";
      break;
      case 11:
        name = "011";
      break;
      case 12:
        name = "012";
      break;
      case 13:
        name = "013";
      break;
      case 14:
        name = "014";
      break;
      case 15:
        name = "015";
      break;
      case 16:
        name = "016";
      break;
      case 17:
        name = "017";
      break;
      case 18:
        name = "018";
      break;
      case 19:
        name = "019";
      break;
    playcomplete(name);
    }
    delay(10);
  }
}

// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  while (wave.isplaying) {
  // do nothing while its playing
  }
  // now its done playing
}

void playfile(char *name) {
  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); Serial.print(name); return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); return;
  }
 
  // ok time to play! start playback
  wave.play();
}

Et voici la liste d'erreurs que j'ai en compilant :

ProgrammationUNO.ino: In function 'void setup()':
ProgrammationUNO:17: error: invalid conversion from 'void (*)()' to 'void (*)(int)'
ProgrammationUNO:17: error: initializing argument 1 of 'void TwoWire::onReceive(void (*)(int))'
ProgrammationUNO.ino: In function 'void receiveEvent()':
ProgrammationUNO:34: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:37: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:40: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:43: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:46: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:49: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:52: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:55: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:58: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:61: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:64: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:67: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:70: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:73: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:76: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:79: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:82: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:85: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:88: error: invalid conversion from 'const char*' to 'char'
ProgrammationUNO:90: error: invalid conversion from 'char' to 'char*'
ProgrammationUNO:90: error: initializing argument 1 of 'void playcomplete(char*)'
ProgrammationUNO.ino: In function 'void playcomplete(char*)':
ProgrammationUNO:100: error: 'wave' was not declared in this scope
ProgrammationUNO.ino: In function 'void playfile(char*)':
ProgrammationUNO:108: error: 'wave' was not declared in this scope
ProgrammationUNO:112: error: 'f' was not declared in this scope
ProgrammationUNO:112: error: 'root' was not declared in this scope
ProgrammationUNO:113: error: 'putstring' was not declared in this scope
ProgrammationUNO:116: error: 'wave' was not declared in this scope
ProgrammationUNO:116: error: 'f' was not declared in this scope
ProgrammationUNO:117: error: 'putstring_nl' was not declared in this scope
ProgrammationUNO:121: error: 'wave' was not declared in this scope


Merci d'avance.
Back to top
Contenu Sponsorisé






PostPosted: Today at 11:48 (2019)    Post subject: Programmation Carte Adafruit Wave Sound

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Simple-Duino Forum Index -> Arduino & Électronique -> Questions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  

Index | Xooit.com free forum | Free support forum | Free forums directory | Report a violation | Conditions générales d'utilisation
Powered by phpBB
Propulsé par Simple-Duino