Show Posts
Pages: 1 ... 31 32 [33] 34 35 ... 79
481  Using Arduino / LEDs and Multiplexing / Re: RGB LED easy smooth colour transitions on: April 25, 2013, 06:41:14 pm
What Headroom said is correct. You wil notice that there are lower and upper thresholds for the LEDs defined in the code. This was to ensure that the really big jumpiness that you get at the lower end (when the LED suddenly turns on) was avoided. In hindsight, it may have been better to have a threshold for each colour (R, G, B) as they seem to respond differently. However, it was good enough for me at the time and I still enjoy my little LED changer on the desk at work smiley

@Headroom - Thanks, this was the first real project I did and on the Arduino early in 2012, about 2 months after I started with the hardware. Lots of water under the bridge since then and I post most of my reasonable stuff on the site in my signature below.
482  Using Arduino / Audio / Re: Piezo MIDI Drums on: April 25, 2013, 02:47:50 am
why it doesnt work with two midi msg at the same time?

Probably because of the 5ms delay waiting for the dignal. If you hit botrh at the same time one will be registered and the other has probably disappeared by the time you have finished checking and sent the messge out the port.

To fix this you would have to rewrite the functions without delay statements. One approach may be to just remove the delay you have now and just see if that works better.
483  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.
484  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.

#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);


void MidiTX(unsigned char StatusByte, unsigned char Note, unsigned char 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++)

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.
485  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.
486  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.
487  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.
488  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,154549.0.html
489  Using Arduino / Project Guidance / Re: Magnetic rotary encoder Code on: April 22, 2013, 04:46:21 pm
Was there a question?

Actually there was no punctuation at all. I inferred a question  smiley-cool
490  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.
491  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.
492  Using Arduino / Programming Questions / Re: modulo with negative int on: April 22, 2013, 05:12:49 am

Intro paragraph gives you the answer.

Moderator edit: Tags removed
493  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)?
494  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.
495  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?
Pages: 1 ... 31 32 [33] 34 35 ... 79