Show Posts
Pages: 1 ... 2119 2120 [2121] 2122 2123 ... 3233
31801  Using Arduino / Programming Questions / Re: Help! Arduino Joystick on: December 07, 2011, 05:18:34 am
Code:
  int analogInput_1 = 2;  analogInput_2 = 3;
  int value_1 = 0;  value_2 = 0;
Multiple declarations in one statement are separated by commas, not semicolons. Even better, though, would be to simply not do this. Use one statement per variable declaration. Trust me, you'll really appreciate doing this as your code gets larger.

Code:
  beginSerial(9600);
That should be Serial.begin(9600); That author was using some pre-release version of the Arduino software, many, many years ago, apparently. Otherwise, the author is an idiot.
31802  Using Arduino / Programming Questions / Re: Webswitch programing? on: December 07, 2011, 04:56:21 am
Quote
Sry but i don't understand the arduino language. I only know some basics law, not more.
Head over to Gigs and Collaborations, then. Offer to pay someone to write the code for you. I've already done 90% of the work. It isn't rocket science to look at the changes that have been made to your code that doesn't compile, and see how to change the rest of the code.

If you won't (not can't) do it, then you'll need to pay someone else to do it.
31803  Using Arduino / Programming Questions / Re: handling the analog input values on: December 07, 2011, 04:44:47 am
You might want to look at the map() function. Map the range 0 to 1024 to 0 to 31 to get values between 0 and 30. Map from 0 to 1024 to 0 to 30, and add 1, to get values in the range 1 to 30.
31804  Using Arduino / Programming Questions / Re: Interrupt/Exit a running sketch? on: December 06, 2011, 12:51:04 pm
Quote
Any help?
Same thing that is always advised. Get rid of all the calls to delay().

Look at the blink without delay() example to see how to use millis() to determine when it is time to do something, instead. Just like you would, with just a watch.
31805  Using Arduino / Programming Questions / Re: Reading analog pins writing them in an array... i don't know why but it works! on: December 06, 2011, 12:41:53 pm
Quote
how is it possible that this works? is it a "magic" trick of the code?
No, of course not. A0, A1, etc. are #defined, to make it easier to use code, on any Arduino, that needs to use the analog pins as digital pins. A0, on the Mega is assigned the value 54. On other Arduinos, it is assigned the value 14.
31806  Using Arduino / Programming Questions / Re: unknown IR receiver error on: December 06, 2011, 11:45:14 am
Quote
Post the code and the errors, if you need help doing this.
31807  Using Arduino / Interfacing w/ Software on the Computer / Re: Help with choosing a protocol* for sending numbers to arduino on: December 06, 2011, 11:44:00 am
Quote
Why does sending a value like 255 take up three bytes?
As a string, the value is '2', '5', '5'. That's three characters/bytes.
31808  Using Arduino / Networking, Protocols, and Devices / Re: Bluetooth Clarification Needed on: December 06, 2011, 11:37:34 am
Quote
From what i understood all i need to do is to attach the Rx and TX pin to arduino's TX and RX
You also need to connect the grounds. Power to the breakout board will make it more responsive, too.

Quote
all i will print with Serial.print(...) will be sent over the bluetooth, so that i can read it from bluetooth serial port using the internal bluetooth module of my macbook pro is that right?
Yes.

Keep in mind that this is a 3.3V board. If you are connecting it to a 5V Arduino, you may want to have a look at the last link on the sparkfun site on how to connect it safely.
31809  Using Arduino / Interfacing w/ Software on the Computer / Re: Help with choosing a protocol* for sending numbers to arduino on: December 06, 2011, 11:24:17 am
Quote
If sending bytes is much more complex, I really wouldn't want to try it for the time being.
Sending a byte is not. Sending an int or a float is. For now, learn how to send data as a string. If the value is in the range 0 to 255, there will be at most 3 bytes, plus the start and end markers. If you sent the value as a byte (binary), you would reduce that to 1 byte, plus the start and end markers, for a savings of 1 or two bytes.

If you are sending thousands of bytes per minute, reducing that by a factor of 3 is significant. If you are sending a few dozen, it really isn't.
31810  Using Arduino / Programming Questions / Re: unknown IR receiver error on: December 06, 2011, 11:18:28 am
Quote
When i try to upload it says a lot of things are not defined in this scope..
Put them in scope.

Post the code and the errors, if you need help doing this.
31811  Using Arduino / Project Guidance / Re: Project to log input pulses. I'm totaly new, please help. on: December 06, 2011, 10:50:18 am
You could add an SD card shield. Every time a signal of interest occurred, write the date and time to a file. Then, you can move the SD card to a PC and write code there to manipulate the data in any way you like.
31812  Using Arduino / Programming Questions / Re: IR signals to MIDI output via USB on: December 06, 2011, 10:05:42 am
Quote
does it have to be in the form of 0x90, 0x45, etc... or can i just put 90, 45...
90 (base 10) and 0x90 (base 16) are not the same value. 0x90 and 144 are. Either of them could be used. But, why?
31813  Using Arduino / Programming Questions / Re: trouble stopping audio from arduino sound shield on: December 06, 2011, 10:02:32 am
Code:
int lightLevel = analogRead(lightPin);
lightLevel =  map(lightLevel, 0, 900, 0, 255);
lightLevel = map(lightLevel, 0, 900, 0, 255);
lightLevel = constrain(lightLevel, 0, 255);
The value read from the analog pin will be in the range 0 to 1023. What is the actual range that your sensor results in? Why are you mapping twice?

Code:
if(lightLevel >= 60)
{
  root.rewind();
  play(root);
}
else if(lightLevel <= 59)
{
  wave.stop();
}
If the if statement evaluates to false, it is because lightLevel is less than or equal 59. There is no need for the if test on the else line.

Quote
the thing i'm having trouble with, is when the light level goes dark, I want the audio to stop, and for the next song to get ready to play if the light level goes up again...
That explains what you want. What do you actually get?

If you want to do as you suggest, you need to separate the code that finds the next song to play (in play()) from the code that actually plays the song, so that you can create nextSong() and playThatSong() functions.
31814  Using Arduino / Programming Questions / Re: Am I missing a conversion? on: December 06, 2011, 09:38:01 am
Quote
The rest of the code is irrelevant
In your opinion.

Quote
I divide 2 longs to create proportional speed value: speedX, and then I try to turn speedX into that intervalX in which I run my example code.
And the values of those two longs is? The resulting value in speedX is? The value in intervalX is? The values and types of currentMillisX and previosMillisX are?

Quote
do I need to convert my value into a different format so that it works inside that if?
unsigned long would be a better choice to store the value in. The cast is not required.
31815  Using Arduino / Programming Questions / Re: Static members & Inheritance on: December 06, 2011, 09:18:32 am
Quote
The whole system must only have one instance of the structures which is shared by many different classes.
One instance of the structure instance that is shared by all instances of the base and derived classes? Or one instance of the definition of the structure that is shared by all instances of base and derived classes? It isn't clear which you mean.
Pages: 1 ... 2119 2120 [2121] 2122 2123 ... 3233