Show Posts
Pages: 1 ... 26 27 [28] 29 30 ... 86
406  Using Arduino / Storage / Re: Writing to SD after interrupt, need help optimizing on: October 27, 2013, 09:57:37 pm
Put the open in setup() and rather than close, make sure that you flush the data (there will be a function for this) every time you write. This will make sure that the data gets pushed out of the buffer to the SD card. Alternatively you can decide to flush every 10 (or any number you pick) so that you minimise the data loss.

This solution is not robust in case someone pulls the card out, but that requires a whole different approach. Unfortunately, unless you know that the Arduino is shutting down and can 'close' at that time, everything other than what you have already done is a compromise on data integrity.
407  Using Arduino / Sensors / Re: High Pressure LED readout device (need help) on: October 27, 2013, 08:23:16 pm
Quote
Seven hundred and sixty one reasons ?  Ouch.

Is still probably cheaper than getting someone to develop this from scratch, with all the problems you will have later on if you need the instrument serviced.
408  Using Arduino / Storage / Re: Writing to SD after interrupt, need help optimizing on: October 27, 2013, 08:18:57 pm
One thing that comes to mind is opening the file once only rather than each time through loop(). The file variable is global so the scope is already ok. I would also probably either write to the file or the Serial port (I assume the latter is for debugging). Serial comms may de disabling interrupts (not sure here...).
409  Using Arduino / Project Guidance / Re: Programming Midi Shield for Arduino on: October 22, 2013, 07:17:20 am
I would suggest that you start by turning a note off when you have released the button (after the while loop). Note off is the same as note on with the velocity set to zero. You have already done note on.
410  Using Arduino / Sensors / Re: Possible to build sound impact sensor instead of buying one? on: October 22, 2013, 01:26:59 am
Google "electret microphone arduino" and you will gets lots.
411  Using Arduino / Project Guidance / Re: Programming Midi Shield for Arduino on: October 21, 2013, 10:52:20 pm
Code:
while(button(BUTTON1) || button(BUTTON2) || button(BUTTON3));
This waits until you have stopped pressing the button.

It seems to me easiest to just send a note off command once the button is not pressed (ie, straight after this part of the code).  I am not sure that you will hear anything if you just sent a note on then note off immediately afterwards.

Note this will only work because you have this busy loop in your code (bad practice, actually). In a more general environment you would detect when a button goes from off to on, send the note on, then detect when the button goes from on to off and send the note off. An alternative way is to do it after a certain time, in which case the technique is similar to the blinkwithoutdelay example.

Also know that a note on command with a 0 velocity is the same as note off.
412  Using Arduino / Programming Questions / Re: Help pulling data out of a seperate void function and turning it into variables. on: October 19, 2013, 10:15:50 pm
Quote
The thing is, the CM value changes quickly from the first ultrasonic to the second
I still don't get what the problem is, sorry. I am not sure what you mean by an 'ultrasonic'. do mean a reading or a sensor?

How many sensors do you have?

If this is the code you are using, what exactly are you trying to do in loop()? Whatever it is, just write the code - at least we will have a starting point.
413  Using Arduino / Sensors / Re: MQ7 Sensor Module Analog Output on: October 19, 2013, 10:06:40 pm
 Vcc is generally connected to the 5V (or 3.3V) supply. Datasheet says Vc for this sensor is 5V. Most sensor breakout boards will have pins for GND, Voltage and Signal (GVS).
414  Using Arduino / Programming Questions / Re: Help pulling data out of a seperate void function and turning it into variables. on: October 19, 2013, 01:40:26 pm
Your question is not that clear and your code does not seem to be complete.

All the distance values are stored in an array called cm. so cm[0] is the first, cm[1] is the second, etc. The cm array declared with global scope which is ok given your intended use.
415  Using Arduino / Project Guidance / Re: Programming Midi Shield for Arduino on: October 18, 2013, 05:48:30 pm
Please use code tags (the # button on the post screen) around your code. It makes it easier to read. You can edit you previous post to correct this.

I am guessing from your question that you don't understand the way MIDI notes work. You can search for this on the internet, but this link should get you started http://www.music-software-development.com/midi-tutorial.html

Once you have read that, you will understand what this does
Code:
  if(button(BUTTON1) || button(BUTTON2) || button(BUTTON3))
  {
   
    noteOn(0x95,0x3C,0x45);
    digitalWrite(STAT2,LOW);
    while(button(BUTTON1) || button(BUTTON2) || button(BUTTON3));
  }

The same note is sent no matter which button is pressed. This is what you want to change with the note of your choice to something more like this:
Code:
  if(button(BUTTON1)
  {
    noteOn(0x95,0x3C,0x45);
    digitalWrite(STAT2,LOW);
  }
   if(button(BUTTON2)
  {
    noteOn(<something else>);
    digitalWrite(STAT2,LOW);
  }   
  if(button(BUTTON3)
  {
    noteOn(<something else again>);
    digitalWrite(STAT2,LOW);
  }
while(button(BUTTON1) || button(BUTTON2) || button(BUTTON3));

btw, I am really not in favour of the while statement locking out anything from happening while one of the button is pressed. This may be ok in test code but it is really bad practice and you should try and get used to working in a more asynchronous manner (look up finite state machines and also get familiar with the techniques used in the BlinkWithoutDelay example).
416  Using Arduino / Project Guidance / Re: Programming Midi Shield for Arduino on: October 18, 2013, 03:22:26 am
What have you got so far (code and circuits)?
417  Using Arduino / Programming Questions / Re: Is there any way to "delay()" (or equivalent) within an interrupt? on: October 17, 2013, 03:42:15 am
Code:
    STATE = digitalRead(2);
    if (STATE == 0){
      StopforHuman(); // Ouroboros ;)
    }

is the same as

Code:
while (digitalRead(2) == 0)
  ; // do nothing

with no recursion.

You do know that the processor will appear to just stop and actually do nothing while this loop is running?
418  Using Arduino / LEDs and Multiplexing / Re: Led Matrix 8x8 x5 max7219 on: October 16, 2013, 04:43:24 pm
Don't forget that you can always attach a file to tthe post, it does not have to be text in the post itself. Look at the additional options menu at the bottom of the post edit text box.
419  Using Arduino / Sensors / Re: MQ7 Sensor Module Analog Output on: October 15, 2013, 09:24:34 pm
Have you googled "MQ7 Arduino" - I am sure you are not the first. Also it is worthwhile getting the datasheet for the MQ7 - try "MQ7 datasheet pdf" in google.

You can only do a linear interpolation if the sensor is linear. The response curve will be on the datasheet information. It looks pretty linear and they also give good ideas on the responsiveness, etc

Lowest analog value (0) will be the lowest value for the voltage and the highest (1023) will be the highest value. Not sure where you get 50 and 170.

Also the sensor is for CO, not CO2 (my mistake), so soft drink will not work.

420  Using Arduino / Sensors / Re: MQ7 Sensor Module Analog Output on: October 15, 2013, 08:14:37 pm
The gas insoft drinks is C02, so if you can capture that in an upside down jar then you are sure that the concentration is very high.
Pages: 1 ... 26 27 [28] 29 30 ... 86