Show Posts
Pages: 1 ... 4 5 [6]
76  Forum 2005-2010 (read only) / Troubleshooting / Re: Wave shield! SD Problems!! on: April 02, 2010, 11:31:34 am
Ah, the link to the sketch guide is here: http://www.ladyada.net/make/waveshield/libraryhc.html
77  Forum 2005-2010 (read only) / Troubleshooting / Wave shield! SD Problems!! on: April 02, 2010, 11:30:50 am
Hi guys i am new in the forum.
I just finished to solder all my wave shield for arduino. I formatted my SD card in FAT16 mode as said on the website and now I am running the dapHC sketch that should test the SD and then playing the audio files inside in a loop. But apparently, there is some issue!

I uploaded the sketch inside my arduino and I opened the serial monitor.. this is what i got:

Wave test!
Free RAM: 696
Error: Card init. failed!
SD I/O error: 1, 0

Please let me know if you have any clues.. I should use this stuff in less then a week for a uni project!

Thanks a lot :o
78  Forum 2005-2010 (read only) / Interfacing / Re: telephone Keypad + wave shield on: April 29, 2010, 12:25:11 pm
OK! It works perfectly!
I got the correct values in the serial monitor,, for each pin. Now I just need to insert this keypad library inside of my wave shield software for trigger audio.
Any help? THANKS AGAIN

this is my software for the wave shield working with grounded pin

// plays the stdintro menu as long as the receiver is lifted (pin #14 open)

#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 4000  // button debouncer

// 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() {
 // set up serial port
 Serial.begin(9600);
 putstring_nl("WaveHC with 6 buttons");
 
  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);

 // pin13 LED
 pinMode(13, OUTPUT);

 // enable pull-up resistors on switch pins (analog inputs)
 digitalWrite(14, HIGH);
 digitalWrite(15, HIGH);
 digitalWrite(16, HIGH);
 digitalWrite(17, HIGH);
 digitalWrite(18, HIGH);
 digitalWrite(19, HIGH);

 //  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!
 }
 
 // Lets tell the user about what we found
 putstring("Using partition ");
 Serial.print(part, DEC);
 putstring(", type is FAT");
 Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?
 
 // Try to open the root directory
 if (!root.openRoot(vol)) {
   putstring_nl("Can't open root dir!"); // Something went wrong,
   while(1);                             // then 'halt' - do nothing!
 }
 
 // Whew! We got past the tough parts.
 putstring_nl("Ready!");
}

int thetrack = 0;
int playpoem = 0;
int buttonpressed = 0;

// ----------------- LOOP ----------------- LOOP ----------------- LOOP ----------------- LOOP -----------------
void loop() {
putstring_nl("loop");


 while (digitalRead(14) == HIGH) { // check if the receiver id lifted
    
     buttonpressed = (check_switches());
    
     if (buttonpressed != 0 ) { // if buttons has been pressed
            putstring("button pressed:"); Serial.println(buttonpressed);
            if (thetrack == 0) { // check in witch menu we are
                putstring_nl("button pressed on stdintro");
                wave.stop();
                thetrack = 1;
            }
              
            else if (thetrack == 1) { // check in witch menu we are
                putstring_nl("button pressed on menu");
                playpoem = 1;
                switch (buttonpressed) {
                  case 1:
                    wave.stop();
                    thetrack = 2; // plays poem #1 (thetrack -1)
                    break;
                  case 2:
                    wave.stop();
                    thetrack = 3;
                    break;
                  case 3:
                    wave.stop();
                    thetrack = 4;
                    break;
                  case 4:
                    wave.stop();
                    thetrack = 5;
                    break;
                }
            }
                
            else {  // if we are playing a poem
                putstring_nl("button pressed on poems");
                wave.stop();
                thetrack = 0; // torna al menu principale
            }    
       }
      
   if (!wave.isplaying) {
     if (thetrack <= 1) {
       playtrack (thetrack);
     }
     else if (thetrack > 1) {
         if (playpoem == 0) {
         thetrack = 0;
         playtrack (thetrack);
         }
         else if (playpoem == 1) {
         playtrack (thetrack);
         playpoem = 0;
         }
     }  
   }
  
      
   // playloop (thetrack);
   }
  
  putstring_nl("phoneoff_wave_stopped");
  wave.stop();
}
// ----------------- ENDLOOP -----------------

/*
// Plays a track in loop
void playloop (byte trackID) {
    if (!wave.isplaying) {
     playtrack (trackID);    
 }
}
*/

// Translates file index to files name
/*
WAVE FILES INDEX:
0 STDINTRO.WAV
1 MENU.WAV
... add below if needed
*/
void playtrack (byte track) {
   switch (track) {
     case 0:
      playfile("STDINTRO.WAV");
      break;
     case 1:
      playfile("MENU.WAV");
      break;
     case 2:
      playfile("POEM1.WAV");
      break;
     case 3:
      playfile("POEM2.WAV");
      break;  
 }
}

// Plays files and print their name
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
 putstring("Playing file: "); Serial.println(name);
 wave.play();
}

int check_switches()
{
 static byte previous[5];
 static long time[5];
 byte reading;
 byte pressed;
 byte index;
 pressed = 0;

 for (byte index = 0; index < 5; ++index) {
   reading = digitalRead(15 + index);
   if (reading == LOW && previous[index] == HIGH && millis() - time[index] > DEBOUNCE)
   {
     // switch pressed
     time[index] = millis();
     pressed = index + 1;
     break;
   }
   previous[index] = reading;
 }
 // return switch number (0 - 5)
 return (pressed);
}



and this is the keypad sketch program


/*  Keypadtest.pde
*
*  Demonstrate the simplest use of the  keypad library.
*
*  The first step is to connect your keypad to the
*  Arduino  using the pin numbers listed below in
*  rowPins[] and colPins[]. If you want to use different
*  pins then  you  can  change  the  numbers below to
*  match your setup.
*
*  Note: Make sure to use pullup resistors on each of
*  the rowPins.
*/
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
 {'1','2','3'},
 {'4','5','6'},
 {'7','8','9'},
 {'#','0','*'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 9, 8, 7, 6 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 12, 11, 10 };

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

#define ledpin 13

void setup()
{
 digitalWrite(ledpin, HIGH);
 Serial.begin(9600);
}

void loop()
{
 char key = kpd.getKey();
 if(key)  // same as if(key != NO_KEY)
 {
   switch (key)
   {
     case '*':
       digitalWrite(ledpin, LOW);
       break;
     case '#':
       digitalWrite(ledpin, HIGH);
       break;
     default:
       Serial.println(key);
   }
 }
}

79  Forum 2005-2010 (read only) / Interfacing / telephone Keypad resistors problem! on: April 28, 2010, 12:39:32 pm
Hello guys,

I am trying to figure out how to use a keypad from an old telephone (i need it for an installation) with the keypad tutorial of the arduino playground.. but i am not sure about resistors!

this is the tutorial i am talking about: http://www.arduino.cc/playground/Main/KeypadTutorial

this is my keypad: http://yfrog.com/1q74485607j

this is how i think it works (the red number): http://yfrog.com/11keypadpindiagramj

Any chance of getting this done?
Thanks a lot..

Can you help me? thanks a lot
80  Forum 2005-2010 (read only) / Interfacing / Arduino switch for seven 220v bulb on: November 25, 2010, 09:28:57 am
Hello there,

I have never done anything with 220v and arduino. Can someone please tell where to start from? I need to order the right components to get the thing started. I guess i need a relay and resistors but i don't have a clue on which to get... i need to switch on and off 7 different 220v bulb, one at the time.
Pages: 1 ... 4 5 [6]