Simple Sketch for Wave shield help needed.

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Kevinator108
 
Posts: 11
Joined: Tue Jul 19, 2016 3:08 pm

Simple Sketch for Wave shield help needed.

Post by Kevinator108 »

I am a VERY novice Arduino hobbyist. Identifying my needs regarding the help I seek, let me first state I am in need of a very low tech solution. I am slightly embarrassed to need help with something as simple as this might be to some, but I am stumped. All examples I have looked at are way more complicated than what I need. I have one very short .wav sound file that is a steel on steel clang noise. I want to use the one sound to replace the buzzer in the original sketch I found online by robotix.com.au. Below is the sketch I want to modify to play my audio file instead of the buzzer: PLEASE HELP!!! Thanks. Kevin.
Basically and LDR picks up a laser and activates an LED and buzzer. I want my sound instead of the buzzer.

The circuit in action can be seen on youtube and instructables under 2 minute laser target:

Code: Select all

  
int ldrPin = A4;     // the cell and 10K pulldown are connected to a0
int sirenPin = 11;  //pin 3 selected!!
int ledPin = A0;
long ldrValue1, ldrValue2;

  
void setup(void) {
   pinMode (sirenPin,OUTPUT);  // set the siren pin as output
   pinMode (ledPin,OUTPUT);  // set the siren pin as output
   pinMode (ldrPin,INPUT);  // set the siren pin as output
   //Serial.begin(9600);  
}
 
void loop(void) {
  ldrValue1 = analogRead(ldrPin);  
  delay(10);
  ldrValue2 = analogRead(ldrPin);  

  if (ldrValue1-ldrValue2 > 20||ldrValue2-ldrValue1 > 20){
  digitalWrite(sirenPin,HIGH);
  digitalWrite(ledPin,HIGH);
  delay(1000);
  }
  else{

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Simple Sketch for Wave shield help needed.

Post by adafruit_support_mike »

Do you already have the Wave Shield, or are you still thinking about what hardware to use.

The FX Board and a small amplifier would be more suited to the behavior you described, and easier to trigger.

User avatar
Kevinator108
 
Posts: 11
Joined: Tue Jul 19, 2016 3:08 pm

Re: Simple Sketch for Wave shield help needed.

Post by Kevinator108 »

Mike, yes I already purchased and assembled the shield. That's why I am becoming frustrated that I am having so much trouble getting it to perform such a seemingly simple task. Instead of handing out more money I would like to get this set-up to work.

I looked at the small FX board (2gb) and think it might work ok. What is the least expensive and user friendly amp you would recommend for this application?

Which FX and which amp do you recommend?

Thanks.

Kev.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Simple Sketch for Wave shield help needed.

Post by adafruit_support_mike »

Any of the FX Boards will work, but if you already have the Wave Shield let's work with that.

The HAL9000 project uses a Wave Shield to play selected sounds, and the code is pretty short and simple: https://learn.adafruit.com/hal-9000-rep ... ing-sounds

It sounds like you'd only want to play one file when the button is pressed instead of choosing a file at random.

User avatar
Kevinator108
 
Posts: 11
Joined: Tue Jul 19, 2016 3:08 pm

Re: Simple Sketch for Wave shield help needed.

Post by Kevinator108 »

Thanks for responding. Correct I want to use an LDR to trigger my one sound effect. Below is a link to the guts of the project, including the sketch I want to use but I want the additional lines to activate the sound file for a noise using my wave shield. As stated I want to eliminate the buzzer. Here is a link that includes the simple sketch.

http://www.instructables.com/id/The-2-M ... t-Circuit/

Thanks.

Kevin.

User avatar
Kevinator108
 
Posts: 11
Joined: Tue Jul 19, 2016 3:08 pm

Re: Simple Sketch for Wave shield help needed.

Post by Kevinator108 »

int ldrPin = A4; // the cell and 10K pulldown are connected to a0
int sirenPin = 11; //pin 3 selected!!
int ledPin = A0;
long ldrValue1, ldrValue2;


void setup(void) {
pinMode (sirenPin,OUTPUT); // set the siren pin as output
pinMode (ledPin,OUTPUT); // set the siren pin as output
pinMode (ldrPin,INPUT); // set the siren pin as output
//Serial.begin(9600);
}

void loop(void) {
ldrValue1 = analogRead(ldrPin);
delay(10);
ldrValue2 = analogRead(ldrPin);

if (ldrValue1-ldrValue2 > 20||ldrValue2-ldrValue1 > 20){
digitalWrite(sirenPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1000);
}
else{

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Simple Sketch for Wave shield help needed.

Post by adafruit_support_mike »

The code on the page linked above has all the information necessary to play a file.

User avatar
Kevinator108
 
Posts: 11
Joined: Tue Jul 19, 2016 3:08 pm

Re: Simple Sketch for Wave shield help needed.

Post by Kevinator108 »

Mike I don't see the code.you refer to as being attached above. Please send again as I can't see it anywhere. Thanks

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Simple Sketch for Wave shield help needed.

Post by adafruit_support_mike »


User avatar
Kevinator108
 
Posts: 11
Joined: Tue Jul 19, 2016 3:08 pm

Re: Simple Sketch for Wave shield help needed.

Post by Kevinator108 »

A sad day for my wave shield indeed.... I got so sick of messing around trying to get it to work with my project. Despite some weak offerings of suggestions, I felt good seeing the board crushed under my hydraulic press. I didn't see the value in that shield on the benefit vs hassle scale. RIP Wave shield and good riddance!! On to something else!

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

Return to “Arduino Shields from Adafruit”