Show Posts
Pages: 1 ... 50 51 [52] 53 54 ... 79
766  Using Arduino / Audio / Re: Alarm buzzer, use delay or cycles? on: January 06, 2013, 01:41:57 pm
Good enough. I have not timed it but when used in multiples (500, 750, 2000) seems to be right. there is also a micros() function for microseconds if you need more accuracy, but I think that is only accurate to within 4 microseconds or so.

In case it helps to get the concept better, I have attached a small library that I wrote to handle the switches connected to the analog pin on my LCD display. The detection time and the repeat rate use this timing technique.
767  Using Arduino / Programming Questions / Re: guys I gut this question please clarify it to me. on: January 06, 2013, 01:08:17 am
'this->' is a pointer to the object (class instance) that the code is running in.
768  Using Arduino / General Electronics / Re: Equivalent of a mechanical toggle switch on: January 05, 2013, 06:09:22 pm
Toby just beat me on the suggestion of a 4066 IC (quad bilateral switch).
769  Using Arduino / Audio / Re: Library for playing MIDI files from the Arduino on: January 05, 2013, 05:16:58 pm
I do appreciate your time in reviewing. When I used to write software for a living it was amazing how much better code could be when a fresh set of eyes were applied and constructive comments passed.

Yes, there will be a pint release once I can check a few things.
770  Using Arduino / Audio / Re: Alarm buzzer, use delay or cycles? on: January 05, 2013, 05:13:56 pm
Use the millis() function to give you the number of milliseconds since the arduino was turned on.

The techniques is demonstrated in the blink without delay example, but basically you save a copy of the millis() to a variable and then check the current value of millis() until the time is expired. Once that happens, do what you need to do and then save the current value of millis() as the baseline for next time.

In your case you may also need to keep track of where you are in the process (eg, blinking display, displaying message, etc), if you have a sequence of actions.
771  Using Arduino / Audio / Re: Library for playing MIDI files from the Arduino on: January 05, 2013, 05:08:27 pm
Thanks again for the review (nitpick?) smiley

Quote
midihelper.h has no construct like
OK. It has now, but it is only ever included in one file which is protected from re-inclusion.

Quote
n++;  //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< extra n++ in the loop? why ?
Left over from when it was a while loop. Should not affect the functionality though, as the for loop is just a way to limit too many events. Effectively halves the (arbitrary) limit.

Quote
if there is an error should you not close the file ?
Yes absolutely. Interesting is that SDFat did not fail over eepeated teationg with a fle that was not correct. It must handle the case of the open file (or maybe it just doesn't care?).

Quote
some var names are still cryptic e.g. c
This is picky. The char array is local to a block of 5 lines of code! To keep you happy I have renamed it 'h' smiley-razz

Quote
shorter?
Clearly so. I'll do some testing as the original code was proposed as the right code to process the varlen parameters by the MIDI organisation.

Quote
#DEFINE DUMPLN(T) Serial.println(T) ??
The philosophy adopted in the DUMP output is that the \n is at the start of the new line, not at the end of the previous one. This makes it cleaner as I can't always tell where the end may be but am sure when I start a new line. So I need to explicitely use '\n' when I want it. It also makes it easier if I want to add debug as I don't need to worry about the line endings sprinkled through the code.

Quote
style diff between the #ifdef used for void MFTrack::dump(void) and  void MIDIFile::dump(void)
I assume you mean in the header file for the class definition?
I wanted to keep the dump function prototype available at all times so that I don't need #if in the sketch code around a call to the dump() method, even if it is an empty function. However, in the classes, the #if switch will cut out all the code for the MFTRack class, as this is only called by MIDIFile.dump().
I suppose an alternative is an empty inline definition in the class dependent on the #if, but the result isthe same.
772  Using Arduino / General Electronics / Re: Basic question about switches on: January 05, 2013, 05:48:40 am
Because without the resistor to pull up or pull down, when the switch is disconnected the circuit is open, which means the input is floating and can give undefined results. The pull up or pull down ensure that you have a known condition when the circuit disconnects (open circuit).
773  Using Arduino / Programming Questions / Re: Binary value of char * on: January 04, 2013, 09:43:16 pm
Assign the value that you want cast into a char*?
Code:
foo = (char*)55

Not sure if that would work, though.
774  Using Arduino / LEDs and Multiplexing / Re: General U8glib Question on: January 04, 2013, 09:39:56 pm
You can attach files. Click on additional options at the bottom of the page.
775  Using Arduino / Audio / Re: Library for playing MIDI files from the Arduino on: January 04, 2013, 07:03:03 pm
This work is now completed and can be found at  http://code.google.com/p/arduino-code-repository/

Thanks to robtillaart for his great comments and feedback during development.

The library is used to process MIDI files from the SD card. MIDI and SYSEX events are passed to the calling program through callback functions for processing. This allows programmers the flexibility to implement a message to a MIDI synthesiser through serial interface or other output devices,
like a MIDI shield or custom hardware.

Processing of files may may be paused and restarted using methods in the library.

Download the library and see MIDIFile.h for more information if you are interested.
776  Using Arduino / Audio / Re: Alarm buzzer, use delay or cycles? on: January 04, 2013, 05:41:31 pm
As there is no timing information in the function you have supplied, the rest of the code must be calling this function with a frequency that gives you your 500ms time. What if there was different code, like:
Code:
void loop(void)
{
  alarm();
}

Timing would then be different and you need to adjust the loop constants to compensate. Worse, still, if this was in a library, you would not expect it to work differently depending on the speed of the CPU or how busy it is, right?

What I mean by a clock or timer giving you more control is that you get a consistent result no matter what code is surrounding this function and a lot less dependencies between different blocks of code. In the long run that makes for more maintainable code.
777  Using Arduino / Audio / Re: Alarm buzzer, use delay or cycles? on: January 04, 2013, 02:30:14 pm
Quote
the delay function the processor can't continue with other tasks. Is this true?
YES

Look at the 'blink without delay' example as a way of doing things without stopping the rest of the functions from running. Your method can work but you may find that it runs through very very fast and you may not notice the flashing, etc. Relating things back to a clock or a timer will provide better control.
778  Using Arduino / Programming Questions / Re: How do I give an I2C device an address? on: January 04, 2013, 02:22:18 pm
Quote
you can make it whatever you want

... as long as it is unique for the I2C implementation on your project. It should be clear that all devices have unique addresses for a specific implementation.
779  Using Arduino / Audio / Re: Fluxamasynth Bagpipe chanter on: January 04, 2013, 01:39:33 am
There's lots of stuff out in internet land for what these mean. Specifically for just a table of notes and their numbers just Google "MIDI note table".
Here are a couple:
http://computermusicresource.com/midikeys.html
http://www.phys.unsw.edu.au/jw/notes.html

Here's some other links that I found helpful when I was researching my MIDI file library.
MIDI.ORG very detailed but has all the info. Can be confusing at times. http://www.midi.org/techspecs/midimessages.php
More (similar) detail explained differently http://www.gweep.net/~prefect/eng/reference/protocol/midispec.html

BTW, I don't expect you tho think I am stupid, you just need to explain stuff to others in great detail as we cannot guess what you are trying to do, and it can get frustrating.

780  Using Arduino / Audio / Re: Fluxamasynth Bagpipe chanter on: January 03, 2013, 07:01:58 pm
What do you mean by 'adding values'? Assume I am really stupid (which I am about what is in your head) and explain it in detail smiley
Pages: 1 ... 50 51 [52] 53 54 ... 79