I have five accelrometer sensors (MMA 7361) connected to the analog channels of Arduino Duemilanove. I am using the following code to read the data. (I am reading from only one axis from each sensor.)

#include <avr/io.h>
#include <avr/wdt.h>

int sensorValue = 0; // value read from the pot

void setup() 
    Serial.begin(9600); // initialize serial communications at 9600 bps:

void loop() 
    // read the analog values:

    int i=1;



        sensorValue = analogRead(i);




I am using a delay of 10 after reading each sensor. What should the value of the delay I should be using after reading one sensor to get the correct values from the sensors?

  • 1
    Why do you need any delay? – Ignacio Vazquez-Abrams Jan 9 '15 at 17:39
  • No delay is needed. Note however that the serial communication might not be able to keep up. If that happens your Serial.print calls will block/delay until the TX-buffer is no longer full. No big deal, but might be useful to know. – Gerben Jan 9 '15 at 19:13
  • What are you trying to do with the data? This will help us give you an answer about sample rates – portforwardpodcast May 11 '15 at 12:33

A delay is not needed.

What can be more beneficial, though, is making a dummy reading between each real reading. This gives the ADC more of a chance to settle on the right reading without the Sample and Hold capacitor being influenced by the previous reading.

The simplest way is just to duplicate your analogRead line so it's done twice.

| improve this answer | |
  • what is the time required for the ADC to settle on the right reading? – ukg Jan 9 '15 at 18:10
  • You'll find that kind of information in the datasheet. Cross-reference that with the analogRead() code to see what the current settings are. – Majenko Jan 9 '15 at 18:23
  • @ukg You don't need to wait for the ADC to settle for any of the readings, each pin uses a different ADC, and they are continuously tracking the input. – meiamsome Apr 9 '15 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.