Pages: [1]   Go Down
Author Topic: Ebay arduino waveshield  (Read 900 times)
0 Members and 1 Guest are viewing this topic.
Philippines
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i buy wveshield in ebay
http://www.ebay.com/itm/Wave-Sound-Shield-Module-Arduino-Compatible-/270941558061?pt=LH_DefaultDomain_0&hash=item3f1560152d
 
they have a sample code:


/*
This code is show how Arduino Wave Module works with Arduino.
Code is not optimized. Any improving work on it is encouraged.
*/
int RST = 3;
int CLK = 9;
int DAT = 8;
   
   
void setup() {   
   
   
    pinMode(RST, OUTPUT);
    pinMode(CLK, OUTPUT);
    pinMode(DAT, OUTPUT);
   
   
    digitalWrite(RST, HIGH);
    digitalWrite(CLK, HIGH);
    digitalWrite(DAT, HIGH);
   
    digitalWrite(RST, LOW);
    delay(5);
    digitalWrite(RST, HIGH);
    delay(300);
}

void loop() {

  send(0x0000);//play file 0000
  delay(10000);//delay 10 seconds
 
  send(0x0001);//play file 0001
  delay(10000);//delay 10 seconds
 
  send(0x0002);//play file 0002
  delay(10000);//delay 10 seconds
 
  send(0xfff0);//set voice volumn to 0 (turn off)
  delay(3000);
 
  send(0xfff4);//set voice volumn to 4
  delay(3000);
 
  send(0xfff7);//set voice volumn to 7
  delay(3000);
 
  send(0xfffe);// pause
  delay(5000);
  send(0xfffe);//play
 
 
 
  while(1);
}
void send(int data)
{
  digitalWrite(CLK, LOW);
  delay(2);
  for (int i=15; i>=0; i--)
  {
    delayMicroseconds(50);
    if((data>>i)&0x0001 >0)
      {
        digitalWrite(DAT, HIGH);
        //Serial.print(1);
      }
    else
       {
         digitalWrite(DAT, LOW);
        // Serial.print(0);
       }
    delayMicroseconds(50);
    digitalWrite(CLK, HIGH);
    delayMicroseconds(50);
   
    if(i>0)
    digitalWrite(DAT, LOW);
    else
    digitalWrite(DAT, HIGH);
    delayMicroseconds(50);
   
    if(i>0)
    digitalWrite(CLK, LOW);
    else
    digitalWrite(CLK, HIGH);
  }
 
  delay(20);
}

but i try to edit this code to have a button it have a file error can i have help smiley thanks thanks!
i want to have a button when it press the sound play
Logged

France
Offline Offline
Sr. Member
****
Karma: 2
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what is the error you get with button, what do you want to do with button ?

post your code (using # button) with errors, so we can help you a little bit more.
Logged

Philippines
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

what is the error you get with button, what do you want to do with button ?

post your code (using # button) with errors, so we can help you a little bit more.

sir this is my edited code smiley there is no error but the its not working :/
/*
This code is show how Arduino Wave Module works with Arduino.
Code is not optimized. Any improving work on it is encouraged.
*/
int RST = 3;
int CLK = 9;
int DAT = 8;
int button = 4;
   
   
void setup() {   
   
   
    pinMode(RST, OUTPUT);
    pinMode(CLK, OUTPUT);
    pinMode(DAT, OUTPUT);
    pinMode(button, INPUT);

    digitalWrite(button, LOW); /* Set button initially as LOW */

    digitalWrite(RST, HIGH);
    digitalWrite(CLK, HIGH);
    digitalWrite(DAT, HIGH);
   
    digitalWrite(RST, LOW);
    delay(5);
    digitalWrite(RST, HIGH);
    delay(300);
}

void loop() {
if(digitalRead(button) == HIGH){ /* if D2 is HIGH */
  delay(500);  /* Soft Debounce delay for 500mS */
  send(0x0000);//play file 0000
  delay(1000);//delay 10 seconds
 
  send(0xfff7);//set voice volumn to 7
  delay(3000);
 
 
  }
 
 
}
void send(int data)
{
  digitalWrite(CLK, LOW);
  delay(2);
  for (int i=15; i>=0; i--)
  {
    delayMicroseconds(50);
    if((data>>i)&0x0001 >0)
      {
        digitalWrite(DAT, HIGH);
        //Serial.print(1);
      }
    else
       {
         digitalWrite(DAT, LOW);
        // Serial.print(0);
       }
    delayMicroseconds(50);
    digitalWrite(CLK, HIGH);
    delayMicroseconds(50);
   
    if(i>0)
    digitalWrite(DAT, LOW);
    else
    digitalWrite(DAT, HIGH);
    delayMicroseconds(50);
   
    if(i>0)
    digitalWrite(CLK, LOW);
    else
    digitalWrite(CLK, HIGH);
  }
 
  delay(20);
}

i want is when i push the button the sound play smiley then stop
Logged

Pages: [1]   Go Up
Jump to: