Show Posts
Pages: 1 ... 37 38 [39] 40 41 ... 85
571  Using Arduino / Programming Questions / Re: Count Down Code Options on: April 29, 2013, 02:24:28 pm
I have implemented something similar that counts down from 99 seconds that you could adapt. Look in the link below (signature block). Hope it is useful.
572  Using Arduino / Displays / Re: Does anyone know how to address character map of a 16x2 LCD? on: April 27, 2013, 06:49:12 pm
My reading of documentation has been that the LCD displays come with one rom set. Most of the ones I have seen have been the Asian extended characters. I have not found any way to 'switch' the rom code to one of the others sets - they are different part numbers from the manufacturer.
573  Using Arduino / Displays / Re: Does anyone how to address character map of a 16x2 LCD? on: April 27, 2013, 03:31:09 pm
As far as I know you just use the ASCII code for the characters and they will work. Internally they may well be arranged as rows and columns, but that is too detailed for me to want to worry about when I am just trying to print a character.
574  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.
575  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.
576  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.
577  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.
578  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.
579  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.
580  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.
581  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
582  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
583  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.
584  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.
585  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
Pages: 1 ... 37 38 [39] 40 41 ... 85