Show Posts
Pages: [1] 2 3 ... 15
1  Forum 2005-2010 (read only) / Troubleshooting / Re: How much sram is still free? on: October 21, 2009, 06:45:21 pm
Mine is telling me:
Code:
free memory = 1787 memory used = 261
With only the memory checking and serial sending code.
That makes sense as when you get near 1.5k it goes kaput, there must be a few hundred bytes you are unaware of.
And i assume that the remaining 100-200 bytes or so must be taken by the arduino bootloader.
2  Forum 2005-2010 (read only) / Troubleshooting / Re: Serial.print crashes when printing int on: September 26, 2009, 05:44:28 pm
That means that our strings can't be longer than 2KB? O_O
3  Forum 2005-2010 (read only) / Troubleshooting / Re: Want to blink only 1 time? newbie question on: September 20, 2009, 01:07:13 pm
Put this in the setup
Code:
digitalWrite(ledPin, HIGH);  
delay(1000);
digitalWrite(ledPin, LOW);  
4  Forum 2005-2010 (read only) / Troubleshooting / Re: Erm...We got a problem... on: September 20, 2009, 03:26:10 pm
So...what do i have to change to get it to work?
Sorry...I was a bit impatient...
@MEM: I tried 500, 100 and 50, nothing worked...
5  Forum 2005-2010 (read only) / Troubleshooting / Re: Erm...We got a problem... on: September 20, 2009, 01:29:52 pm
I am at the brink of giving up...Does anyone care?
6  Forum 2005-2010 (read only) / Troubleshooting / Erm...We got a problem... on: September 20, 2009, 12:52:26 pm
So i have
Code:
#include <Tone.h>
Tone tone1;
int spkpin = 9;//the speaker (digital PWM)pin is 9
int potpin = 0;//potenmeter(analog) pin
int potpin2= 1;//second potenmeter (analog) pin
int note = 440;//the starting hertz
int minhz = note;//minimum hertz
int maxhz = note*2;//maximum hertz
int way  = 0;//0 and the tone goes lower, 1 and it goes higher
int changespeed = 1;//the speed of changing the note in miliseconds
int rawchangespeed = 1;//the raw data recived from one of the potenmeters
int loopcount = 1;//the times the same sound has been played
int rawnote = 440;//the raw data recived from the potenmeters
void setup()
{
  tone1.begin(spkpin);
  Serial.begin(9600);
}

void loop()
{
  rawchangespeed = analogRead(potpin);//reads the position of the potenmeter
  changespeed = rawchangespeed/300;//lowers the value
  
  rawnote = analogRead(potpin2);
  
  minhz = rawnote;//sets whatever was read as the minimum hertz value
  maxhz = rawnote+rawnote;//sets whatever was read as the maximum hertz value and doubles it
  note = rawnote+5;//sets the current note to the note returned by the potenmeter and adds 5 to it
  
  //debug data
  if(loopcount==100)
  {
  Serial.print("Current note:");
  Serial.print(note);
  Serial.println("");
  
  Serial.print("Min HZ:");
  Serial.print(minhz);
  Serial.println("");
  
  Serial.print("Max HZ:");
  Serial.print(maxhz);
  Serial.println("");
  
  Serial.print("Pot #1 Positon:");
  Serial.print(rawchangespeed);
  Serial.println("");
  
  Serial.print("Pot #2 Positon:");
  Serial.print(rawnote);
  Serial.println("");
  loopcount = 2;
  }
  loopcount = loopcount + 1;
  //debug data end
  
  tone1.play(note);//plays the current note
  
  if (way==0)//if the way the tone is changing to is down
  {
  note = note-5;//subtract 5 hertz from the note
  delay(changespeed);//delay it
  }
  else//or if it is going up
  {
  note = note+5;//add 5 hertz
  delay(changespeed);//delay it
  }
  
  if (note==minhz)//if the note is at the minimun hertz value
  {
    way = 1;//set way to 1, thus making the tone go higher
  }
  
  if (note==maxhz)//if the note is at the maximum herts value
  {
    way = 0;//set way to 0, thus making the tone go lower
  }
  
}
What it does is play a siren like sound by playing a note and raising and lowering the tone, but i got a problem.
I was able to implement the first potentiometer to change the speed of the note changing, but when i put the second part for the second potentiometer, that changes the frequency, it does not change...
The note stays the same, does not go up or down, just stays at one stationary spot...
here is the previous version that works, but does not use the second potenmeter, thus not being able to change the frequency.
Code:
#include <Tone.h>
Tone tone1;
int spkpin = 9;//the speaker (digital PWM)pin is 9
int potpin = 0;//potenmeter(analog) pin
int minhz = 800;//minimum hertz
int maxhz = 900;//maximum hertz
int note = 810;//the starting hertz
int way  = 1;//0 and the tone goes lower, 1 and it goes higher
int changespeed = 1;//the speed of changing the note in miliseconds
int loopcount = 0;//the times the same sound has been played
void setup()
{
  tone1.begin(spkpin);
}

void loop()
{
  changespeed = analogRead(potpin);//reads the position of the potenmeter
  changespeed = changespeed/300;//lowers the value
  tone1.play(note);//plays the current note
  
  if (way==0)//if the way the tone is changing to is down
  {
  note = note-5;//subtract 5 hertz from the note
  delay(changespeed);//delay it
  }
  else//or if it is going up
  {
  note = note+5;//add 5 hertz
  delay(changespeed);//delay it
  }
  
  if (note==minhz)//if the note is at the minimun hertz value
  {
    way = 1;//set way to 1, thus making the tone go higher
  }
  
  if (note==maxhz)//if the note is at the maximum herts value
  {
    way = 0;//set way to 0, thus making the tone go lower
  }
  
//note:this is the working code
}

Any ideas on what i did wrong?
All the debug data is correct, but it still does not work...for some reason...
Thanks
~ReCreate
7  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Example Errors on: September 24, 2009, 03:52:59 pm
But...They don't work, just Fix it! smiley-lol(almost certain that something like this would be that guy's reply, i can't help it  ;D smiley-lol)
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: Calculating RPM's... Problem in code... on: November 19, 2009, 02:05:21 am
Ahh.....ehh.....erm...Yes, I think so, But it's 1 AM, And I'm not sure...I'll take a stab tomorrow...
Thanks
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Calculating RPM's... Problem in code... on: November 18, 2009, 07:17:02 pm
"Do you need a code fragment to illustrate the logic," Yes...
10  Forum 2005-2010 (read only) / Syntax & Programs / Re: Calculating RPM's... Problem in code... on: November 18, 2009, 03:26:00 pm
Ok so i have this
Code:
int cath = 2;//negative of the reciver
int ando = 3;//positive of the reciver
int rpm = 0;//the RPM's variable
int revolutions = 0;//the variable for counting revolutions
int go = false;
int count = 0;//the variable for counting the code loops

void setup()
 {
   pinMode(cath, OUTPUT);
   pinMode(ando, OUTPUT);
   pinMode(13,OUTPUT);
   digitalWrite(13,HIGH);
   Serial.begin(9600);
   Serial.println("Started...");  
 }

void loop()
 {
   digitalWrite(cath, LOW);
   digitalWrite(ando, HIGH);
   digitalWrite(cath, HIGH);
   digitalWrite(ando, LOW);
   pinMode(ando, INPUT);
  
   count =  millis() % 1000;
  
   //Serial.println(digitalRead(ando));//just show me what is getting recived
   if(count<=999)//if we looped for less than about a second
   {
     if(digitalRead(ando) == LOW)//check if we got a revolution
     {
       //off, and that means we got a revolution
       revolutions++;//increment it
     }
   }
   else//if we've been
   {
     rpm = revolutions * 60;//calculates the RPM's
     //output the RPM's
     Serial.print("RPM's: ");    
     Serial.println(rpm);  

   }
    pinMode(ando, OUTPUT);
 }
And it does not work, It is *never* reaching 1000, This is really getting damn frustrating, Nothings working, Any ideas?
11  Forum 2005-2010 (read only) / Syntax & Programs / Re: Calculating RPM's... Problem in code... on: November 18, 2009, 02:43:02 pm
Oh, neat thanks!
12  Forum 2005-2010 (read only) / Syntax & Programs / Re: Calculating RPM's... Problem in code... on: November 18, 2009, 01:53:03 pm
Hmmm... Can you explain that? I don't see how that would work...
13  Forum 2005-2010 (read only) / Syntax & Programs / Re: Calculating RPM's... Problem in code... on: November 18, 2009, 01:15:54 pm
Well, What i wanted is to have some sort of counter that counts to 1 second, and then resets, And for me to be able to know exactly where the timer is at.
So i tried to find out how many loops are in 1 second doing that, So It would loop until it reaches the amount of loops that are equivalent to a second, But that didn't work too well...
14  Forum 2005-2010 (read only) / Syntax & Programs / Re: Calculating RPM's... Problem in code... on: November 17, 2009, 10:22:05 pm
What I want is to reset whatever millis returns back to 0, as if the arduino was reset.
15  Forum 2005-2010 (read only) / Syntax & Programs / Re: Calculating RPM's... Problem in code... on: November 17, 2009, 09:58:19 pm
So...I just add those code snips to my code and it will reset it?
Pages: [1] 2 3 ... 15