Show Posts
Pages: 1 ... 60 61 [62] 63 64 ... 85
916  Using Arduino / Audio / Re: Sending a Midi Note on: November 05, 2012, 05:25:26 am
It turns on an internal pull down resistor when used that way.
917  Using Arduino / Programming Questions / Re: Reading off a Bouncing Push Button on: November 04, 2012, 04:41:40 am
Do you need to use an interrupt at all? If you consider that in the time you press a button the CPU can execute hundreds of thousands of instructions, can you use this speed to adopt a polling mechanism instead, using the techniques shown in blink without delay?
918  Using Arduino / Audio / Re: Sending a Midi Note on: November 04, 2012, 12:10:01 am
When you have a switch wired to an input up you need to have a definite electrical signal for both when it is off and when it is on. When you switch the switch on, you are connecting it to 5V and your get a HIGH in the code. If you simply disconnect the switch and do not pull it down to 0V with through a resistor, then you get a floating input that can flip all over the place. Look up the principle for the "pull down" resistor circuit either on this forum or using google.

The same applies for a circuit that is normally at 5V and is switched to low. In this case the resistor is called a pull-up resistor, but the reasoning behind it is the same.
919  Using Arduino / Audio / Re: Sending a Midi Note on: November 03, 2012, 06:02:29 am
The MIDI standard is 31250.
920  Using Arduino / Audio / Re: Sending a Midi Note on: November 02, 2012, 09:26:56 pm
You should break the problem down into component parts. There are clearly 2 things that you need to do:

1. Read a button and register that this has changed from OFF to ON. There is plenty of example code on how to do this. You should consider debouncing the switch so that you do not read false presses (sounds like you have not from the description).

2. Sending the note to the MIDI device. Again, lots of examples on how to do this (look for MIDI in the Playground) using various libraries trhat will do most of the work for you.

The easiest way to learn is to try writing some simple code from existing examples and then asking for more help when you get stuck.

921  Using Arduino / Programming Questions / Re: Button logic on: November 02, 2012, 02:25:54 pm
Try simplifying some of your statements to make the code more readable. For example

    if (stopgobuttonstate == HIGH)
      if (amigoing == 0) {

is the same as

    if (stopgobuttonstate == HIGH) &&  (amigoing == 0)
922  Using Arduino / Programming Questions / Re: reading serial data with timeouts on: November 02, 2012, 02:21:04 pm
You need to use the same technique as the 'Blink without delay' example.

Before you start checking if a characetr is available on the serial port, you store the current value of millis(). You then loop waiting for a character until either a character arrives or the new current millis() value is bigger than the timeout.
923  Using Arduino / Programming Questions / Re: replace delay() on: November 02, 2012, 02:17:03 pm
Look at the MultiBlink code in the Playground. It is designed to do what you seem to need.
924  Using Arduino / Programming Questions / Re: Run if (or similar) statement once on: October 28, 2012, 05:06:13 am
Libraries are automatically linked in if you use float, so no need to do anything special the.
925  Using Arduino / Programming Questions / Re: My Garduino Project 3 Box design on: October 27, 2012, 11:05:25 pm
I am sure that you will get a lot of help, but you need to be more specific - What is your program supposed to do? What is the problem? What have you already done to try and fix it?
926  Using Arduino / Programming Questions / Re: Run if (or similar) statement once on: October 27, 2012, 08:11:38 pm
So actually, with massively fast inputs, this code would actually work? But only if the denominator is less than 30.

Yes, but you will lose a lot of precision. Using integer maths:
30/1 = 30
30/2 = 15
30/3 = 10
30/4 = 7
30/11 = 2 in fact everthing up to /15 = 2
30/16 thru 30 = 1

This is probably no good for you! Floats will work but are slower (as mentioned) and also reqire libraries that take valuable memory.
927  Using Arduino / Programming Questions / Re: Run if (or similar) statement once on: October 27, 2012, 02:01:31 pm
dpm goes to zero because 10 divided by anything greater than 10 is zero (in integer maths). Even if the multiplication happens first you get the problem with denominator greater than 30.

I am assuming that the key presses will be at least 100ms if they are being done manually, so this calculation will probably never work as you expect.

I would consider combining the rpm & dpm calculations into one and use brackets () to control the flow of calculation so that you do not lose significant digits in the integer maths.
928  Using Arduino / Programming Questions / Re: Run if (or similar) statement once on: October 26, 2012, 11:30:12 pm
Looks to me like this statement at the top of the loop()

dpm = 3 * tooth_spacing / threepulsetimecopy; // causing problem, due to multiplying diff types

will divide by zero (at least on the first loop)?

What is the output of your program - the debug statements?
929  Using Arduino / Programming Questions / Re: Trying to use binary number (B10000) in lib and getting error. on: October 26, 2012, 11:17:43 pm
The binary numbers Bxxxxxxxx (8 digits) are defined in the headers for Arduino.

You can either expand yours to be 8 binary digits (B00010000) or just use the standard C convention 0b10000 (same way as 0x prefix would be used for hex numbers).
930  Using Arduino / LEDs and Multiplexing / Re: Help with cycling multiple LED states within modified Blink without delay on: October 23, 2012, 02:10:45 am
Look at the MultiBlink example in the Playground.

What you may want to do is defined 2 data tables and swap over which one you use to get the different patterns you are lookng for.
Pages: 1 ... 60 61 [62] 63 64 ... 85