Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Forum / Love this site on: January 01, 2010, 07:10:46 pm
This is the greatest.
2  Forum 2005-2010 (read only) / Interfacing / Re: Tone library + accel hang on: February 07, 2010, 03:44:43 pm
Got it.  People who call Tone::begin repeatedly in the loop need their head examined.
3  Forum 2005-2010 (read only) / Interfacing / Re: Tone library + accel hang on: February 07, 2010, 11:54:16 am
Oh, and I did think that the Tone object was getting destroyed so I put it as a global and it made no difference.
4  Forum 2005-2010 (read only) / Interfacing / Re: Tone library + accel hang on: February 07, 2010, 11:53:32 am
Ok - I simplified this and the issue is the tone library

I still get three beeps for the following

Code:
void loop() {

  // Read the accelerometer
//  readAccel();
  Tone tone1;
  tone1.begin(rightBuzzerPin);
  tone1.play(NOTE_A4,550);
  
 // tone2.begin(leftBuzzerPin);
 // tone2.play(NOTE_A4);
 
  delay(600);

}
5  Forum 2005-2010 (read only) / Interfacing / Re: Tone library + accel hang on: February 07, 2010, 11:46:06 am
The x,y,z reappear in the loop.

I tried powering off an external battery.  Very good idea that - you never really know if you're sending enough current.  However, vene then we get three beeps and it stops.  Same as before.

This makes no real sense to me.
6  Forum 2005-2010 (read only) / Interfacing / Re: Tone library + accel hang on: February 07, 2010, 10:55:28 am
Ok - will do.

The sprintf's are a good buffer over-run candidate but would they affect timing here or something?
7  Forum 2005-2010 (read only) / Interfacing / Tone library + accel hang on: February 07, 2010, 10:45:06 am
Guys,

I have a lilypad with the standard accelerometer and a buzzer.  I can read the accel just fine but if I use the tone library as well I can read the accel three times, make three tones, and then it all just hangs.  Is this some wierd interrupt thing?

Code follows .. thx in advance.

#include <Tone.h>
#include <bassdll.h>
#include <debug.h>

#include <stdlib.h> // for malloc and free
void* operator new(size_t size) { return malloc(size); }
void operator delete(void* ptr) { free(ptr); }

//
//  Ardy Jacket
//
//    leds, buzzers (left/right), vibrator, acelerometer
//
//

const int groundPin = 18;             // analog input pin 4 -- ground
const int powerPin = 19;              // analog input pin 5 -- voltage
const int xPin = 16;                   // x-axis of the accelerometer  ANALOG
const int yPin = 17;                   // y-axis  ANALOG
const int zPin = 18;                   // z-axis (only on 3-axis models)  ANALOG


int ledPins[4];
int rightBuzzerPin = 6;
int leftBuzzerPin = 7;
int vibratorPin = 8;
//int x,y,z;

void setup() {

  Serial.begin(9600);

  // Setup led pins
  for (int count = 0; count < 4; count++) {
    ledPins[count] = 2 + count;
    pinMode(ledPins[count], OUTPUT);
  }

  pinMode(leftBuzzerPin, OUTPUT);
  pinMode(rightBuzzerPin, OUTPUT);
  pinMode(vibratorPin, OUTPUT);

  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
  pinMode(zPin, INPUT);
}

// Read the accelerometer.
void readAccel(int &x, int &y, int &z) {

  x = analogRead(xPin);
  y = analogRead(yPin);
  z = analogRead(zPin);

  
}

Tone tone1;
Tone tone2;

void loop() {

  int x = 0, y = 0, z = 0;
  // Read the accelerometer
  readAccel(x,y,z);

  char buffer[56];
  sprintf(buffer, "(x,y,z) = (%d,%d,%d)", x, y, z);
  
  Serial.println(buffer);
  
  sprintf(buffer, "(x,y,z) = (%d)", NOTE_A4  + x / 100);
  
  Serial.println(buffer);

  tone1.begin(rightBuzzerPin);
  tone1.play(NOTE_A4,100 );
  
//  tone2.begin(leftBuzzerPin);
//  tone2.play(NOTE_A4);
 
  delay(800);

}
8  Forum 2005-2010 (read only) / Interfacing / Connectors from pins on: January 16, 2010, 10:49:39 pm
What do folks use to connect pins (like ribbon cable pins) to wires?  I'm looking for individual pin connectors not just ribbon cable terminators.  Part #s would be great if you have them.  smiley-razz
9  Forum 2005-2010 (read only) / Exhibition / Arduino Mp3 capable Thomas table for a toddler on: January 01, 2010, 07:11:41 pm
I'm writing a blog about my three year old's adventures in arduino.  My current pet project is a thomas table that has sensors for trains passing that activate mp3 sounds.  It also plays his favourite tunes when buttons are pressed. There are full code samples and descriptions of how to wire it all up.  I hope y'all enjoy it.

http://sebbiesoft.com/arduino/
Pages: [1]