Show Posts
Pages: 1 ... 37 38 [39] 40 41 ... 85
571  Using Arduino / Programming Questions / Re: Help Needed changing PID constants using a DIP-Switch on: April 23, 2013, 05:01:22 pm
THe scope of your PID object is just within the loop function. Every time the loop function ends the PID object is delected and recreated again the next time tru loop. You need to make the PID object global scope or a static variable.
572  Using Arduino / Audio / Re: Piezo MIDI Drums on: April 23, 2013, 02:49:15 pm
I have tried to simplify the code to make it easier to debug. I have created a function that does everything your code was repeating once to avoid cut an paste and make things more consistent.

Code:
#define  MAX_PIEZO  5

uint8_t piezo[MAX_PIEZO] = { A0, A2, A4, A6, A8 };
uint8_t drumType[MAX_PIEZO] = { 5, 4, 3, 2, 1 };

const int threshold = 500;  

void setup()
{
  for (uint8_t i=0; i<MAX_PIEZO; i++)
    pinMode(piezo[i], INPUT);

  Serial.begin(57600);      
}

void MidiTX(unsigned char StatusByte, unsigned char Note, unsigned char Val)
{
  Serial.write(StatusByte);
  Serial.write(Note);
  Serial.write(Val);
}

void ProcessPiezo(uint8_t p)
{
  uint16_t sensorReading = analogRead(piezo[p]);
  uint16_t  val;

  if (sensorReading > threshold)
  {
    uint32_t oldcas = millis() + 5;
    
    // this part of the code looks complex
    // explain what you are trying to do?
    while (analogRead(piezo[p]) > threshold)
    {
      if (millis() >= oldcas)
      {
        val = analogRead(piezo[p]) / 8;
      }
    }
    
    MidiTX(144, drumType[p], val);
    MidiTX(128, drumType[p], val);
  }
}

void loop()
{
  for (uint8_t i=0; i<MAX_PIEZO; i++)
    ProcessPiezo(i);
}

So the question is what do you mean by delay? How long? milliseconds, seconds, minutes?

There is a 5ms delay built into you code when you detect a value > threshold, but I imagine that you don't mean that.
Your code also used int for a millis() value instead of unsigned long, so I changed that. In some cases that could have caused delays until the counter wrapped around again.

Try what is there now, verify that you still have a problem and then give us more details.

You can also try to capture the output using the serial monitor on the computer (avoid all the MIDI) and if the message is there instantaneously, you knoew the delay is after that in the MIDI software chain on the PC.
573  Using Arduino / Project Guidance / Re: Debounce interrupt pin, pullups on, res/cap combo? on: April 23, 2013, 06:35:42 am
Page 32 doesn't have what you need? Ok.
574  Using Arduino / LEDs and Multiplexing / Re: Problem with MAX7219 on: April 22, 2013, 05:06:01 pm
You will need to post your cirtcuit and your code. If you don't have a circuit, pictures of your (breadboard?) setup would be ok.

Hard to help if we can't see what is made.
575  Using Arduino / Programming Questions / Re: Can't use function in setup on: April 22, 2013, 05:00:46 pm
The function is spelt differently. You have swapped the s and the h in the call from setup.
576  Using Arduino / Project Guidance / Re: Debounce interrupt pin, pullups on, res/cap combo? on: April 22, 2013, 04:57:38 pm
Have a look at http://arduino.cc/forum/index.php/topic,154549.0.html
577  Using Arduino / Project Guidance / Re: Magnetic rotary encoder Code on: April 22, 2013, 04:46:21 pm
Quote
Was there a question?

Actually there was no punctuation at all. I inferred a question  smiley-cool
578  Using Arduino / Programming Questions / Re: Removing elements from array on: April 22, 2013, 03:28:16 pm
An alternative approach for the elevator problem would be to have an array representing the number of floors, which does not change much, and if the elevator needs to go there put a 1 in the array element for the floor. For example, if I need to go to floor 3 then array element 3 has a 1 in it. No rearranging necessary and if the elevator is going past the floor it can just stop there by checking whether the floor has been requested.
579  Using Arduino / Programming Questions / Re: Removing elements from array on: April 22, 2013, 06:48:17 am
Post your code because there must be something wrong somewhere.
580  Using Arduino / Programming Questions / Re: modulo with negative int on: April 22, 2013, 05:12:49 am
http://en.wikipedia.org/wiki/Modulo_operation

Intro paragraph gives you the answer.


Moderator edit: Tags removed
581  Community / Bar Sport / Re: Be DIFFERENT! make good posts! on: April 21, 2013, 09:58:35 pm
I am confused by the rant, to be honest.

For my own clarity, are you flaming about the content of posts (mostly written by beginners or people learning), the spelling mistakes (of non english speakers, for the most part) or the books people write (which has probably nothing to do with this forum)?
582  Using Arduino / Displays / Re: IIC/I2C/TWI 2004 20X4 Character LCD Module Display on: April 21, 2013, 07:32:08 pm
Can you compile any other software (eg, the blink sketch)? This establishes a baseline for whether your installation actually works.

Can you also try and just include LiquidCrystal.h (even if it does not ultimately work wih the hardware) to see if that will compile?

Are you including all the required libraries?

Which Arduino and what operating system on the computer?

Posting the actual error message would be helpful.
583  Using Arduino / Displays / Re: lcd graphic design on: April 21, 2013, 05:11:09 pm
Is this the sort of thing you are looking for? http://mikeyancey.com/hamcalc/lcd_characters.php
584  Using Arduino / Project Guidance / Re: Magnetic rotary encoder Code on: April 21, 2013, 05:02:22 pm
People will be more willing to help if you post the code you have written rather than expecting others to write it for you.

In case you don't know where to start:
1. You will need to sire up the sensor and verify that it works manually (ie, see the transition from 0-1) by either turning on a LED or writing to the serial display.
2. Once you have done this, then test it with the disk and see that you can detect when the disk rotates. Each time the transition from 0 to 1 (or 1 to 0) happens, then add count to some counter.
3. Once the counter reaches your required value, do whatevere you need (in this case turn on a LED).

All these smaller 'projects' are easy if you look for examples in this forum or on the web.
585  Using Arduino / Programming Questions / Re: 8x8 LED Matrix Pattern on: April 21, 2013, 03:00:51 am
Can you be more specific about what you mean?

Do you mean software to display the patterns or software to create the bitmaps to display on the screen?
Pages: 1 ... 37 38 [39] 40 41 ... 85