Show Posts
Pages: [1]
1  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 30, 2013, 03:22:13 am
would this one do the trick?
http://www.adafruit.com/products/248
2  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 26, 2013, 08:08:23 pm
okay awesome!
Also whats a good power source if i wanna unplug it from my computer?
Would 12v battery pack be efficient?
3  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 23, 2013, 12:09:27 am
okay, ive been sick for a few days so i havnt had a chance to look anything over.
So basically what im wanting the servos to do is. With the slider potentiometer one servo goes clockwise 180 degrees. and then the other servo goes 180 counter clockwise. And i just want it to follow the slider and read its position basically.
How can i use this new code for that?
4  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 20, 2013, 09:57:47 pm
So how can i strengthen my servo code? im fairly new to all this.
And basically i wanted the sounds to play when the board came online then be able to control my servos.
Im looking at your merging code info now. Trying to make sense of everything.
5  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 20, 2013, 05:01:11 am
okay i finally GOT IT ALL WORKING! its playing perfectly fine now. and i got a speaker wired to it as well!
ONE MORE FINAL THING I ASK OF YOU GUYS!
how do im implement these two codes together

Code:
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"


SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

#define DEBOUNCE 5  // button debouncer
// Global variables
int num=0;
char toPlay[8]; // file to play 00.WAV to 99.WAV

// This handy macro lets us determine how big the array up above is, by checking the size

// this handy function will return the number of bytes currently free in RAM, great for debugging!   
int freeRam(void)
{
  extern int  __bss_end;
  extern int  *__brkval;
  int free_memory;
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end);
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
  }
  return free_memory;
}

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  byte i;
 
  // set up serial port
  Serial.begin(9600);
  putstring_nl("WaveHC with ");

  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad
  Serial.println(freeRam());      // if this is under 150 bytes it may spell trouble!
 
  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  // initilise file extension part of file to play
  toPlay[2] = '.';
  toPlay[3] = 'W';
  toPlay[4] = 'A';
  toPlay[5] = 'V';
  toPlay[6] = '\0'; // terminator

 
    //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {         //play with 8 MHz spi (default faster!) 
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!
  }
 
  // enable optimize read - some cards may timeout. Disable if you're having problems
  card.partialBlockRead(true);

// Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;                             // we found one, lets bail
  }
  if (part == 5) {                       // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why
    while(1);                            // then 'halt' - do nothing!
  }
 
 // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);
  }
 
// Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);
  }

  playcomplete( "IMPORTIN.wav");
  playcomplete( "ONLINE.wav");
}


void loop() {
  if(Serial.available() > 0) {
    num = Serial.read();
    num -= 0x30;
   // Serial.println(num,HEX);
  makeName(num);
  playfile(toPlay);
  delay(1000);
   // wave.stop();   
   }
}

void makeName(int number){  // generates a file name 00.WAV to 99.WAV
  int i=0;
  if(num > 9) {
  toPlay[0] = ((num/10) & 0xf) | 0x30;
  toPlay[1] = ((num%10) & 0xf) | 0x30;
  }
  else {
  toPlay[0] =  0x30;
  toPlay[1] = (num & 0xf) | 0x30;
  }
}

// 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_nl("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();
}

the code for the wave shield, and this code for my servos

Code:

#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
Servo myservo2;  // create servo object to control a servo
 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
int potpin2 = 1;  // analog pin used to connect the potentiometer0
int val2;    // variable to read the value from the analog pin
 
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo2.attach(8);  // attaches the servo on pin 9 to the servo object

}
 
void loop()
{
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 20, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(5);                           // waits for the servo to get there
 
  val2 = analogRead(potpin2);            // reads the value of the potentiometer (value between 0 and 1023)
  val2 = map(val2, 0, 1023, 180, 20);     // scale it to use it with the servo (value between 0 and 180)
  myservo2.write(val2);                  // sets the servo position according to the scaled value
  delay(5); 


// waits for the servo to get there
 
6  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 18, 2013, 07:17:30 pm
So i have my code all ready. But when i power on arduino. It doesnt seem to play. Ive tried a speaker and the head phone jack. any idea why?

heres my code
Code:
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"


SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

#define DEBOUNCE 5  // button debouncer
// Global variables
int num=0;
char toPlay[8]; // file to play 00.WAV to 99.WAV

// This handy macro lets us determine how big the array up above is, by checking the size

// this handy function will return the number of bytes currently free in RAM, great for debugging!   
int freeRam(void)
{
  extern int  __bss_end;
  extern int  *__brkval;
  int free_memory;
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end);
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
  }
  return free_memory;
}

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  byte i;
 
  // set up serial port
  Serial.begin(9600);
  putstring_nl("WaveHC with ");

  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad
  Serial.println(freeRam());      // if this is under 150 bytes it may spell trouble!
 
  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  // initilise file extension part of file to play
  toPlay[2] = '.';
  toPlay[3] = 'W';
  toPlay[4] = 'A';
  toPlay[5] = 'V';
  toPlay[6] = '\0'; // terminator

 
    //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {         //play with 8 MHz spi (default faster!) 
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!
  }
 
  // enable optimize read - some cards may timeout. Disable if you're having problems
  card.partialBlockRead(true);

// Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;                             // we found one, lets bail
  }
  if (part == 5) {                       // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why
    while(1);                            // then 'halt' - do nothing!
  }
 
 // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);
  }
 
// Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);
  }

  playcomplete( "IMPORTIN.wav");
  playcomplete( "ONLINE.wav");
}


void loop() {
  if(Serial.available() > 0) {
    num = Serial.read();
    num -= 0x30;
   // Serial.println(num,HEX);
  makeName(num);
  playfile(toPlay);
  delay(1000);
   // wave.stop();   
   }
}

void makeName(int number){  // generates a file name 00.WAV to 99.WAV
  int i=0;
  if(num > 9) {
  toPlay[0] = ((num/10) & 0xf) | 0x30;
  toPlay[1] = ((num%10) & 0xf) | 0x30;
  }
  else {
  toPlay[0] =  0x30;
  toPlay[1] = (num & 0xf) | 0x30;
  }
}

// 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_nl("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();
}
7  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 17, 2013, 04:22:29 pm
okay. I cant seem to get it working...
How do i integrate this 
Code:
void setup()
{

<all the SD initialization and whatever else is already there>

playcomplete("FILE1.WAV");

playcomplete("FILE2.WAV");

} // end of setup()

into what you gave me before?
Code:
/*
  SERIAL TO SAMPLE - By Mike Cook Nov 2010
  Based on the Lady Ada code
  This will take a byte from the serial port and play the sample corresponding to the ASCII character
  received minus 0x30, so for example if it receives '2' (ASCII 0x32) it will play the sample file 02.WAV
*/
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"


SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

#define DEBOUNCE 5  // button debouncer
// Global variables
int num=0;
char toPlay[8]; // file to play 00.WAV to 99.WAV

// This handy macro lets us determine how big the array up above is, by checking the size

// this handy function will return the number of bytes currently free in RAM, great for debugging!   
int freeRam(void)
{
  extern int  __bss_end;
  extern int  *__brkval;
  int free_memory;
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end);
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
  }
  return free_memory;
}

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  byte i;
 
  // set up serial port
  Serial.begin(9600);
  putstring_nl("WaveHC with ");

  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad
  Serial.println(freeRam());      // if this is under 150 bytes it may spell trouble!
 
  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  // initilise file extension part of file to play
  toPlay[2] = '.';
  toPlay[3] = 'W';
  toPlay[4] = 'A';
  toPlay[5] = 'V';
  toPlay[6] = '\0'; // terminator

 
    //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {         //play with 8 MHz spi (default faster!) 
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!
  }
 
  // enable optimize read - some cards may timeout. Disable if you're having problems
  card.partialBlockRead(true);

// Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;                             // we found one, lets bail
  }
  if (part == 5) {                       // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why
    while(1);                            // then 'halt' - do nothing!
  }
 
 // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);
  }


void loop() {
  if(Serial.available() > 0) {
    num = Serial.read();
    num -= 0x30;
   // Serial.println(num,HEX);
  makeName(num);
  playfile(toPlay);
  delay(1000);
   // wave.stop();   
   }
}

void makeName(int number){  // generates a file name 00.WAV to 99.WAV
  int i=0;
  if(num > 9) {
  toPlay[0] = ((num/10) & 0xf) | 0x30;
  toPlay[1] = ((num%10) & 0xf) | 0x30;
  }
  else {
  toPlay[0] =  0x30;
  toPlay[1] = (num & 0xf) | 0x30;
  }
}

// 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_nl("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();
}
8  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 17, 2013, 05:29:03 am
Youre freaking awesome -.-!!! So i ran the code and from what i can tell its working.
It just says done uploading. I havent gotten a finished compiling or anything yet.
So heres another question. I still want it to play some audio files when it gets powered on.
And i have another sketch that controls servos. Can i just add it to the bottom of this one or vice versa?
9  Community / Gigs and Collaborations / Re: Help with WaveShield coding! on: May 17, 2013, 02:24:07 am
I saw another posting you replied to about where i need sd reader and some other things under import library. I dont have that, I have WAVE HC under it though.
And other then that, i have under sketchbook libraries, is wave hc then some examples.
When i load the sd card initializer im getting a "AF_wave is not a type"
10  Community / Gigs and Collaborations / Help with WaveShield coding! on: May 17, 2013, 01:05:50 am
Hello everyone!
So i have my arduino and i just got a waveshield from Adafruit. I have it assembled and on my arduino ready to go.
Where can i look for code to play sound when my arduino turns on? Basically when the arduino chip receives power it will play the sounds. I cant really seem to find any tutorials on waveshields.
11  Community / Gigs and Collaborations / Re: Help with controlling servo with Slider potentiometer on: May 11, 2013, 08:13:40 pm
okay lol! i got them working. Now heres another question. I coded and plugged in another servo. So the slider is controlling two servos.
How do i get the second servo to spin counter clockwise while the first one spins  clockwise. Heres what i have, I thought it was something to do with the number values. But i couldnt find any tutorials or anything on them.

 val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 20, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(5);                           // waits for the servo to get there
 
  val2 = analogRead(potpin2);            // reads the value of the potentiometer (value between 0 and 1023)
  val2 = map(val2, 0, 1023, 20, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo2.write(val2);                  // sets the servo position according to the scaled value
  delay(5);
12  Community / Gigs and Collaborations / Help with controlling servo with Slider potentiometer on: May 09, 2013, 08:07:50 pm
Hello everyone!
Im using an Arduiono Uno to control a servo with a Slider Potentiometer.
Everything seems to be hooked up properly. But, for some reason the potentiometer doesnt
work what so ever. As if its not getting a signal.
Im using the basic "knob" example sketch. But, i changed the slider from pin 0 to pin 7. Heres the code


#include <Servo.h>
 
Servo myservo;
 
int potpin = 7; 
int val;   
 
void setup()
{
  myservo.attach(9);   
}
 
void loop()
{
  val = analogRead(potpin);           
  val = map(val, 0, 1023, 0, 179);     
  myservo.write(val);                 
  delay(15);                           
}

Will a slider work with this? Or do I need to basic clockwise/counter clockwise turning potentiometer.
Either way, any help would be awesome!
Also the servo works and nothings wrong with the board! Ill upload the "blink sketch" or the "sweep" sketch and it works fine.
13  Community / Gigs and Collaborations / help with coding on: February 07, 2013, 02:55:41 am
Hello everyone!

So i need help with coding, as i am quite new. But! i have everything set up and working cause it works on the test and example coing.
Anyways!
heres what i got!
Im using an Arduino uno!
So i have my servos plugged into my breadboard and they run to Pin9.
So i need to program them to on a push of a button rotate back 180 and stop until i push the button again and then rotate forward 180.

Now i dont have a button yet. But isnt there a way to test it inside the arduino program itself?
14  Community / Gigs and Collaborations / Help for a complete Newbie! on: January 19, 2013, 10:33:18 pm
Hello everyone!

Im completely new to servos and programming them! I really need help with what im wanting to do. I've searched thousands of forums and asked help from many people even people from hobbyking and no one really REALLY helps me at all. They assume you know everything and just answer one question and its not even a direct answer smiley-sad So im hoping you brilliant people here can help me out with my project.

So heres what i want to do.
Im using Servos to Lift a Faceplate off a mask. More specifically the iron man helmet. I want to be able to control when it opens and closes with the push of a button. There are several people who do this and none of them really want to help us out. An example of what im asking can be seen here :

So Theres a really good example and i basically want to do exactly that. But to be more acurate the jaw slightly opens as well. All this runs off the servos which is connected to a HINGE system. So when the servo moves back 180 degres the hinge system lifts the face piece up and also will slightly open the jaw.

The hinge system I can do. Its just servos and everything like that. I have no idea what to do guys :/

First of all, what exactly do I need? a list of everything.
I know ill be at least using 2 servos. And i saw someone else has this problem, they posted a few days ago. But i still would like help fellas.
But if you guys could help me out, bascially tell me how you would do it, with a list of parts you'd use(i.e servos controller boards and whatever else I would need).
and how i would program it to do so. And also a button or how i would do that.
Any help would be appreciated guyS!!!!!
Pages: [1]