Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Sketches can not be called main Change of IDE 22 on: January 16, 2011, 07:28:36 am
It the way I was taught in college.

I usually call test programs main, falls back to my first C++ class.
2  Forum 2005-2010 (read only) / Troubleshooting / Sketches can not be called main Change of IDE 22 on: January 16, 2011, 03:25:03 am
A new change in 22 that was not noted.

You can not name a sketch as main.
This causes strange compiler errors where it will not find the included files.

as such

main.pde
Main.pde
MAIN.pde

will not compile

but

mainx.pde
Mainx.pde
ect

will compile

the errors you get are
Code:


main.cpp.o: In function `main':
....\arduino/main.cpp:7: undefined reference to `setup'
....\arduino/main.cpp:7: undefined reference to `loop'
3  Forum 2005-2010 (read only) / Troubleshooting / Sound effect on: January 13, 2011, 04:31:54 pm
Hi i have been trying for a little while to make a sound effect play on the aruino.

I am trying to get the Iconic pacman death sound to play.


The code that i attempted to use to create this sound effect is listed below.

I haven't made much headway on this because i am not good at composing music at all, if someone could write a snipit of code for that sound i would be grateful

Code:
#include <Tone.h>
Tone tone1;
#define OCTAVE_OFFSET 0
int notes[] = { 0,
NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4,
NOTE_C5, NOTE_CS5, NOTE_D5, NOTE_DS5, NOTE_E5, NOTE_F5, NOTE_FS5, NOTE_G5, NOTE_GS5, NOTE_A5, NOTE_AS5, NOTE_B5,
NOTE_C6, NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6,
NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7
};
//char *song = "Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8b,p,8f,p,4f#";
//char *song = "MahnaMahna:d=16,o=6,b=125:c#,c.,b5,8a#.5,8f.,4g#,a#,g.,4d#,8p,c#,c.,b5,8a#.5,8f.,g#.,8a#.,4g,8p,c#,c.,b5,8a#.5,8f.,4g#,f,g.,8d#.,f,g.,8d#.,f,8g,8d#.,f,8g,d#,8c,a#5,8d#.,8d#.,4d#,8d#.";
//char *song = "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5,e,32f,e,32f,c#,d#.,c#";
char *song = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d";
//char *song = "smb:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16c7,16p,16c7,16c7,p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16d#6,8p,16d6,8p,16c6";
//char *song = "SMBUndergr:d=16,o=6,b=100:c,c5,a5,a,a#5,a#,2p,8p,c,c5,a5,a,a#5,a#,2p,8p,f5,f,d5,d,d#5,d#,2p,8p,f5,f,d5,d,d#5,d#,2p,32d#,d,32c#,c,p,d#,p,d,p,g#5,p,g5,p,c#,p,32c,f#,32f,32e,a#,32a,g#,32p,d#,b5,32p,a#5,32p,a5,g#5";
//char *song = "SMBWater:d=8,o=6,b=225:4d5,4e5,4f#5,4g5,4a5,4a#5,b5,b5,b5,p,b5,p,2b5,p,g5,2e.,2d#.,2e.,p,g5,a5,b5,c,d,2e.,2d#,4f,2e.,2p,p,g5,2d.,2c#.,2d.,p,g5,a5,b5,c,c#,2d.,2g5,4f,2e.,2p,p,g5,2g.,2g.,2g.,4g,4a,p,g,2f.,2f.,2f.,4f,4g,p,f,2e.,4a5,4b5,4f,e,e,4e.,b5,2c.";
//char *song = "smbdeath:d=4,o=5,b=90:32c6,32c6,32c6,8p,16b,16f6,16p,16f6,16f.6,16e.6,16d6,16c6,16p,16e,16p,16c";
void setup(void)
{
  Serial.begin(9600);
  tone1.begin(13);
}
#define isdigit(n) (n >= '0' && n <= '9')
void play_rtttl(char *p)
{
  // Absolutely no error checking in here
  byte default_dur = 4;
  byte default_oct = 6;
  int bpm = 63;
  int num;
  long wholenote;
  long duration;
  byte note;
  byte scale;
  // format: d=N,o=N,b=NNN:
  // find the start (skip name, etc)
  while(*p != ':') p++;    // ignore name
  p++;                     // skip ':'
  // get default duration
  if(*p == 'd')
  {
    p++; p++;              // skip "d="
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    if(num > 0) default_dur = num;
    p++;                   // skip comma
  }

  Serial.print("ddur: "); Serial.println(default_dur, 10);
  // get default octave
  if(*p == 'o')
  {
    p++; p++;              // skip "o="
    num = *p++ - '0';
    if(num >= 3 && num <=7) default_oct = num;
    p++;                   // skip comma
  }
  Serial.print("doct: "); Serial.println(default_oct, 10);
  // get BPM
  if(*p == 'b')
  {
    p++; p++;              // skip "b="
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    bpm = num;
    p++;                   // skip colon
  }
  Serial.print("bpm: "); Serial.println(bpm, 10);
  // BPM usually expresses the number of quarter notes per minute
  wholenote = (60 * 1000L / bpm) * 4;  // this is the time for whole note (in milliseconds)
  Serial.print("wn: "); Serial.println(wholenote, 10);


  // now begin note loop
  while(*p)
  {
    // first, get note duration, if available
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    
    if(num) duration = wholenote / num;
    else duration = wholenote / default_dur;  // we will need to check if we are a dotted note after

    // now get the note
    note = 0;

    switch(*p)
    {
      case 'c':
        note = 1;
        break;
      case 'd':
        note = 3;
        break;
      case 'e':
        note = 5;
        break;
      case 'f':
        note = 6;
        break;
      case 'g':
        note = 8;
        break;
      case 'a':
        note = 10;
        break;
      case 'b':
        note = 12;
        break;
      case 'p':
      default:
        note = 0;
    }
    p++;

    // now, get optional '#' sharp
    if(*p == '#')
    {
      note++;
      p++;
    }

    // now, get optional '.' dotted note
    if(*p == '.')
    {
      duration += duration/2;
      p++;
    }
  
    // now, get scale
    if(isdigit(*p))
    {
      scale = *p - '0';
      p++;
    }
    else
    {
      scale = default_oct;
    }
    scale += OCTAVE_OFFSET;
    if(*p == ',')
      p++;       // skip comma for next note (or we may be at the end)

    // now play the note
    if(note)
    {
      Serial.print("Playing: ");
      Serial.print(scale, 10); Serial.print(' ');
      Serial.print(note, 10); Serial.print(" (");
      Serial.print(notes[(scale - 4) * 12 + note], 10);
      Serial.print(") ");
      Serial.println(duration, 10);
      tone1.play(notes[(scale - 4) * 12 + note]);
      delay(duration);
      tone1.sto  
4  Forum 2005-2010 (read only) / Interfacing / Re: SDuFAt With Arduino Mega (1280 or 2560) on: November 21, 2010, 05:28:31 am
Running the LS example with the modified quarterspeed, 53 line returns this
Code:
Type any character to start
Free RAM: 6942
Volume is FAT16

Files found in root:
128661~1.PNG  2010-10-09 04:31:54 306078
128902~1.JPG  2010-11-06 04:41:46 441175
EST.TXT       2010-11-21 04:25:44 0

Files found in all dirs:
128661~1.PNG
128902~1.JPG
EST.TXT

Done
5  Forum 2005-2010 (read only) / Interfacing / Re: SDuFAt With Arduino Mega (1280 or 2560) on: November 21, 2010, 05:24:07 am
I formatted the SD card with this http://www.sdcard.org/consumers/formatter/ to remove the partition error.

Info returns this now.

Code:
type any character to start

init time: 401883

Card type: SD2

Manufacturer ID: 2
OEM ID: TM
Product: SA02G
Version: 0.3
Serial number: 1411765916
Manufacturing date: 5/2009

cardSize: 3854336 (512 byte blocks)
flashEraseSize: 128 blocks
eraseSingleBlock: true

part,boot,type,start,length
1,0,6,135,3854201
2,0,0,0,0
3,0,0,0,0
4,0,0,0,0

Volume is FAT16
blocksPerCluster: 64
clusterCount: 60214
fatStartBlock: 136
fatCount: 2
blocksPerFat: 236
rootDirStart: 608
dataStartBlock: 640

type any character to start
6  Forum 2005-2010 (read only) / Interfacing / Re: SDuFAt With Arduino Mega (1280 or 2560) on: November 21, 2010, 05:21:13 am
I got it to work, I changed the speed value to 1/4
Code:
pinMode(53, OUTPUT);                       // set the SS pin as an output (necessary!)
  digitalWrite(53, HIGH);                    // but turn off the W5100 chip! (not applicable)
  uint8_t r = card.init(SPI_QUARTER_SPEED, 53);  // Use digital 53 as the SD SS line



and the info returned this
Code:
type any character to start

init time: 968

Card type: SD2

Manufacturer ID: 2
OEM ID: TM
Product: SA02G
Version: 0.3
Serial number: 1411765916
Manufacturing date: 5/2009

cardSize: 3854336 (512 byte blocks)
flashEraseSize: 128 blocks
eraseSingleBlock: true

part,boot,type,start,length
1,80,6,63,3854273
2,0,0,0,0
3,0,0,0,0
4,0,0,0,0

Volume is FAT16
blocksPerCluster: 64
clusterCount: 60215
fatStartBlock: 71
fatCount: 2
blocksPerFat: 236
rootDirStart: 543
dataStartBlock: 575
Data area is not aligned on flash erase boundaries!
7  Forum 2005-2010 (read only) / Interfacing / Re: SDuFAt With Arduino Mega (1280 or 2560) on: November 20, 2010, 01:32:50 am
no sd card
Code:
card.init failed
SD error
errorCode: 1
errorData: 0
 
type any character to start
8  Forum 2005-2010 (read only) / Interfacing / SDuFAt With Arduino Mega (1280 or 2560) on: November 20, 2010, 12:38:03 am
I am currently trying to get SD card reading to work on my Arduino Mega.
I currently have both Mega models to test on (the 1280 & the 2560).

The adapter I'm using for my SD card is this one
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=3&products_id=55&zenid=uqe03c4n47l2o82i8g47ubq563
With this shield to couple it to the Mega
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=18&products_id=231

I am using the library, SDFAT

http://code.google.com/p/sdfatlib/downloads/list

I have modified the SD2pinmap.h lines 41 to 45 to this
Code:
// SPI port
uint8_t const SS_PIN = 49;      // SC 53 or 49???
uint8_t const MOSI_PIN = 52;    // data out
uint8_t const MISO_PIN = 50;    //data in
uint8_t const SCK_PIN = 51;     // CLK

I am trying to get the example SDfatinfo.pde to work, and modified the code from line 148 to 150.
Code:
pinMode(53, OUTPUT);                       // set the SS pin as an output (necessary!)
  digitalWrite(53, HIGH);                    // but turn off the W5100 chip! (not applicable)
  uint8_t r = card.init(SPI_HALF_SPEED, 53);  // Use digital 53 as the SD SS line


Running the gets this reply in the serial monitor (comments were added manually and are the different cards
Code:
//32MB Cannon

card.init failed
SD error
errorCode: 2
errorData: FF

type any character to start

//2nd 32MB Cannon

card.init failed
SD error
errorCode: 2
errorData: FF

type any character to start

//128MB Kodak

init time: 344

Card type: SD1
readCID failedSD error
errorCode: F
errorData: FF

type any character to start

//2BG Kingston MicroSD+adapter

init time: 624

Card type: SD2
readCID failedSD error
errorCode: E
errorData: FF

type any character to start

//4GB PNY SHDC microsd+adpater

init time: 359

Card type: SDHC
readCID failedSD error
errorCode: E
errorData: 1F


Can someone help me pinpoint why I can't read the info of any of the cards?
9  Forum 2005-2010 (read only) / Interfacing / Re: Help adapt AVR code for Stronglink RFID on: November 19, 2010, 01:27:52 am
I can't seem to get this library to work.
I compile and upload with no errors.
When I open the serial monitor the commands return their respective text, but nothing involving the RFID tags come back.
R comes back with Read and thats it.

Is their a special syntax I need t use?
Pages: [1]