# Delay and sampling rate

**URL:** <https://forum.arduino.cc/t/delay-and-sampling-rate/950604>\
**Category:** Sensors\
**Created:** [January 24, 2022, 7:19am UTC](https://forum.arduino.cc/t/delay-and-sampling-rate/950604 "2022-01-24T07:19:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![puvivarman](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@puvivarman](https://forum.arduino.cc/u/puvivarman)\
**Post date:** [January 24, 2022, 7:19am UTC](https://forum.arduino.cc/t/delay-and-sampling-rate/950604/1 "2022-01-24T07:19:00Z")

</div>

What is the need of delay after serial.print and will it affect the ADC sampling rate.

In the following code the ADC sampling rate is 9.6KHz by default, and will delay(100) in loop affect sampling rate.

void setup() {  
// initialize serial communication at 9600 bits per second:  
Serial.begin(2000000);  
}

// the loop routine runs over and over again forever:  
void loop() {

// read the input on analog pin 0 and 1:  
float a0 = analogRead(A0);  
// print out the value you read:  
Serial.println(a0 \* 5 / 1024);  
delay(100);  
}

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [January 24, 2022, 7:19am UTC](https://forum.arduino.cc/t/delay-and-sampling-rate/950604/2 "2022-01-24T07:19:56Z")

</div>

> [@puvivarman](#):
>
> In the following code

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'  
  
Use [color = red] **code tags** [/color] (the \</\> icon above the compose window)&nbsp;to make it easier to read and copy for examination

> [@How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966):
>
> See also [FAQ - Arduino Forum](https://forum.arduino.cc/faq) for general rules on forum behavior and etiquette. Hello, Welcome to the Arduino Forum. This guide explains how to get the best out of this forum. Please read and follow the instructions below. Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frus…

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [January 24, 2022, 7:24am UTC](https://forum.arduino.cc/t/delay-and-sampling-rate/950604/3 "2022-01-24T07:24:24Z")

</div>

> [@puvivarman](#):
>
> What is the need of delay after serial.print and will it affect the ADC sampling rate.

delay(100); // 100ms

That delay is to slow down the output to the serial monitor so things don't scroll too fast for you to read.

1/2 second might be even better 😉

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [July 23, 2022, 7:25am UTC](https://forum.arduino.cc/t/delay-and-sampling-rate/950604/4 "2022-07-23T07:25:21Z")

</div>

Closed on July 23, 2022, 7:25am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
