Show Posts
Pages: 1 ... 29 30 [31] 32 33 ... 86
451  Using Arduino / Audio / Re: Connect a piezo sensor board to audio-jack on: September 15, 2013, 11:35:59 pm
All the GND should be connected together (Arduino, Piezo, jack).
452  Using Arduino / Audio / Re: Connect a piezo sensor board to audio-jack on: September 15, 2013, 07:11:35 pm
You are going to have to give us more clues as to the application you are trying to do.

Generally all the grounds in a circuit need to be connected together or the 'ground' will be different in the different part of the system.
453  Using Arduino / Programming Questions / Re: Newbie question about introductory Blink example on: September 09, 2013, 09:59:06 pm
The LED is part of a circuit that 'starts' at the positive side (+5V) and 'ends' at GND (which is zero volts). Energy 'flows' from the higher to the lower voltage and can do useful stuff when it flows.

The reason we don't reference ground is that in this case we switch on the high(er) voltage using the Arduino pin. The LOW setting for the pin is zero volts, the HIGH setting is 5V. So when you are in LOW state, the pin and GND are at the same voltage and nothing happens (no energy flows). When you switch the pin to HIGH, the voltage differential makes the LED light as it flows, using up some of the energy.

NB. This is not a completely accurate electronic description, but as you seem to be a real newbie, hopefully this explains what is happening.
454  Community / Exhibition / Gallery / Re: Scrolling LED matrix display - Parola for Arduino on: September 09, 2013, 09:50:01 pm
Some breaking news.

Tayda Electronics (http://www.taydaelectronics.com) are starting a kit section in additon to their component store and will be carrying instructions for Parola on their kits website http://www.taydakits.com/instructions/parola-for-arduino. They are now also stocking the LED matrix displays and right angle edge sockets, so you can buy all the parts from one source. I am hoping that they will eventually sell these as a kit, including the Parola PCB, which will make it more accessible to everyone.
455  Using Arduino / Programming Questions / Re: Problem with MIDI, Pitch, and Pointers on: September 05, 2013, 08:59:01 pm
Points on programming:
Code:
void load_note(){
  int n = 0;
  int i = 0;
  while (n = 0 and i < 88) {
    if (ArreLEDs[i][1] == -1) {
      ArreLEDs[i][1] = note;
      ArreLEDs[i][2] = velocity;
      n=1;
    }
    i += 1;
  }
}
It is worth defining 88 as a symbolic constant eg #define MAX_LEDS 88
I would define a structure for the data rathar than an array of 3 elemnts. Then define an array of structures.
This may be better written as
Code:
for (uint8_t i=0; i<MAX_LEDS, i++)
    if (ArreLEDs[i][1] == -1)
    {
      ArreLEDs[i][1] = note;
      ArreLEDs[i][2] = velocity;
      break; // break out of the lop when we find a place to store new data
   }
What is the consequence of not finding a spot to store the new data (ie, array is full?)

Code:
void TurnOff_Note(){
  int n = 0;
  int i = 0;
  int aux;
  while (n = 0 and i < 88) {
    if (ArreLEDs[i][1] == note){
      aux = i;
    }
    if (ArreLEDs[i][1] == -1){
      if (aux == i-1){
        ArreLEDs[aux][1] = -1;
        ArreLEDs[aux][2] = -1;
      }
      else{
        ArreLEDs[aux][1] = ArreLEDs[i-1][1];
        ArreLEDs[aux][2] = ArreLEDs[i-1][2];
      }
    }
    i += 1;
  }
}
Are there circumstances that you could be using aux before it has been given a value? Also, it looks like you are trying to crunch up the array so that there are no empty spaces - this is not really necessary. You just process the whole array and set the completed notes to -1. This space will then be reused as soon as a new note comes in.

456  Using Arduino / Programming Questions / Re: Problem with MIDI, Pitch, and Pointers on: September 05, 2013, 08:47:48 pm
Can you be more specific? What is it doing (or not doing) compared to what you see happening?
457  Using Arduino / Programming Questions / Re: Problem with MIDI, Pitch, and Pointers on: September 05, 2013, 06:51:36 pm
Sorry, I missed the new in the code.

Generally, I would be in favour of linked lists and structures that minimise the amount of processing time required. That is how I learned to program using Unix, VMS, Windows, etc, when you want to be as efficient as possible with CPU time.

However, in the Arduino platforms, the biggest constraint is usually RAM memory. There is just not much of it (eg, the Uno has 2kb). So everything you can do to reduce the memory footprint is a good thing. This means that you need to be really careful about the heap and heap fragmentation can be a big problem if you are allocating and releasing RAM. You could run out and then be stuck (there are no cleanup routines from the Operating System, as there is no OS). Recursion is also not such a great idea for the same reason - you quickly run out of stack space (although with tail recursion the compiler may optimise this out, but I wouldn't rely on it.

For example, this "int ArreLEDs[88][3]={0};" uses about 10% of your RAM (264 bytes).

The most secure and safest option is to use static RAM. This would allow you to remove the two pointers from your structures (saving 4 bytes of RAM per structure) and simplifies your code.

I agree it is not as elegant, but it is safer. And you have CPU to burn in this application, so the relative inefficiency is not worth worrying about in this case, imho. You are still doing loops in your code, they just happen to be recursive.

In principle, you code should work, but I would regard it as unsafe programming for a platform like the Arduino.
458  Using Arduino / Programming Questions / Re: Problem with MIDI, Pitch, and Pointers on: September 04, 2013, 09:56:41 pm
Code:
void load_notes(struct tag *&ptr
should definitely be
Code:
void load_notes(struct tag *ptr

Code:
(*ptr).pressedKey
is more usually written as
Code:
ptr->pressedKey

Nowhere are you actually allocating any space for the thing you are pointing to. A pointer needs to point to something. Usually for the sort of atructure you are implementing (soubly linked list) you would allocate memory space for the thing and then the pointers point to it.

Personally, I would be implementing this as a static array, as you only have a set number of notes (128?) and it would simplify everything else for you.
459  Using Arduino / General Electronics / Re: Eagle as schematic software on: September 02, 2013, 09:39:43 pm
I tried Eagle, then got fed up with the painful non-standard Windows interface, tried as few others, then came back to Eagle. The others were more intuitive, but ultimately I found the 'compatibility' issue to be more important.

It is a pain to get used to and I go through the process every time I pick it up because I don't use it all the time, but it seems to be widely used and there are a lot of libraries for it. I am sure I can be more productive (write scripts, learn more, etc) but as a casual user I make do. The autorouting for PCBs works well and it is supported by Seeed, which is where I get my boards made.

460  Using Arduino / Storage / Re: EEPROM help for a noob on: September 02, 2013, 09:16:13 pm
What John said +

You also have some battery backed RAM (if you have the clock coin battery installed) in the DS1307 that can store data. This is accessible throught the I2C interface. Same deal - you probably don't want to rewrite the data every time, but it is an alternative to the EEPROM. See my code repository (link below) for my library that allows access to this memeory if your current version does not.
461  Using Arduino / Audio / Re: play & sync a midi file to external clock on: September 01, 2013, 10:13:18 pm
Ok, your call. I still think it is possible but I don't have any of the equipment to try it.

And, just to make sure I was not doing something silly in the example code, I checked
Code:
  err = SMF.load();
  if (err != -1)
  {
462  Using Arduino / Displays / Re: ANN: TallFont Library for LiquidCrystal (HD44780) on: September 01, 2013, 09:33:11 pm
Looks a lot like mine (see link below - code repository).

Amazing how we get to the same place from different angles.
463  Using Arduino / Audio / Re: play & sync a midi file to external clock on: September 01, 2013, 07:03:34 pm
Quote
If I have a MIDI noteOn callback, would it interfere with the MIDIfile handler, or does the MIDIfile handler only 'do stuff' for MIDI coming from the file on the sd card?

There is no logical reason it should (but that does not mean that it does not).

The MIDI library reads a serial port and then calls a callback to tell you a certain type of message has been received. The MIDIFile library reads the SD card and calls the callback for the user to deal with the MIDI event (which could be a message). If you want to you could use the MIDI library to send the message - that is what I used to do before I simplified the example code to reduce the dependency on yet another library (MIDI). The MIDIFile library boils down to reading a file on the SD card, interpreting the bytes (especially wrt timing) and then calling the callback to make the user handle the MIDI event however they want.

Code:
  int err;
  if (err != -1)
  {

I still don't see what this does. Variable err has an undefined value when you are checking for -1 as you have done nothing with it.

I don't understand what you are trying to do with the code you posted. You cannot just assume that the MIDI file will be synched wih the other MIDI stream because there will be timing and latency issues with the comms, as well as slight differences in the clocking between Arduino and synthesiser. So the MIDI streams' synch will progressively diverge (small changes accumulated over a longer time) unless they are resynched on a periodic basis. That's the whole point of the time beat messages - to minimise or eliminate these differences - by sending a beat 96 times per note (a lot, IMHO, but who am I to argue!).
464  Using Arduino / Audio / Re: play & sync a midi file to external clock on: September 01, 2013, 12:46:38 am
Leave the midifile library out and see if the NoteOn callback works.

I don't see any reason why the two libs can't work together as I originally was using the midi library as a way to send messages from midi file before I realized I could just send my own message through the serial port.

465  Using Arduino / Programming Questions / Re: Use Array to Blink More Than One Pin on: August 31, 2013, 08:36:33 pm
Add another parameter to your function and pass in the length of the array for the function to use.  The when you call the function, use the sizeof calculation as the parameter to the function.
Pages: 1 ... 29 30 [31] 32 33 ... 86