mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
Added delays to some serial examples to avoid crashing the serial monitor.
This commit is contained in:
parent
6f93d3fc17
commit
bde00b9be9
@ -9,7 +9,7 @@
|
||||
* 8-ohm speaker on digital pin 8
|
||||
|
||||
created 21 Jan 2010
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -41,5 +41,4 @@ void loop() {
|
||||
tone(8, notes[thisSensor], 20);
|
||||
}
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* 4.7K resistor on analog 0 to ground
|
||||
|
||||
created 21 Jan 2010
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -36,7 +36,7 @@ void loop() {
|
||||
|
||||
// play the pitch:
|
||||
tone(9, thisPitch, 10);
|
||||
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* LED connected from digital pin 9 to ground
|
||||
|
||||
created 29 Dec. 2008
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -46,8 +46,8 @@ void loop() {
|
||||
Serial.print("\t output = ");
|
||||
Serial.println(outputValue);
|
||||
|
||||
// wait 10 milliseconds before the next loop
|
||||
// wait 2 milliseconds before the next loop
|
||||
// for the analog-to-digital converter to settle
|
||||
// after the last reading:
|
||||
delay(10);
|
||||
delay(2);
|
||||
}
|
||||
|
@ -10,9 +10,9 @@
|
||||
* Analog sensor (potentiometer will do) attached to analog input 0
|
||||
|
||||
Created 22 April 2007
|
||||
modified 30 Aug 2011
|
||||
By David A. Mellis <dam@mellis.org>
|
||||
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
http://www.arduino.cc/en/Tutorial/Smoothing
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -61,7 +61,8 @@ void loop() {
|
||||
// calculate the average:
|
||||
average = total / numReadings;
|
||||
// send it to the computer as ASCII digits
|
||||
Serial.println(average);
|
||||
Serial.println(average);
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
created 2006
|
||||
by David A. Mellis
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe and Scott Fitzgerald
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -36,7 +36,7 @@ void loop() {
|
||||
Serial.println(analogRead(A0));
|
||||
// wait a bit for the analog-to-digital converter
|
||||
// to stabilize after the last reading:
|
||||
delay(10);
|
||||
delay(2);
|
||||
}
|
||||
|
||||
/* Processing code for this example
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
Created 26 Sept. 2005
|
||||
by Tom Igoe
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe and Scott Fitzgerald
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -33,6 +33,10 @@ void setup()
|
||||
{
|
||||
// start serial port at 9600 bps:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
pinMode(2, INPUT); // digital sensor is on digital pin 2
|
||||
establishContact(); // send a byte to establish contact until receiver responds
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
connected to pin 13, so you don't need any extra components for this example.
|
||||
|
||||
created 17 Jan 2009
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -51,6 +51,6 @@ void loop() {
|
||||
|
||||
// print the analog value:
|
||||
Serial.println(analogValue);
|
||||
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
* 10K resistor from analog in 0 to ground
|
||||
|
||||
created 1 Jul 2009
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -22,7 +22,8 @@
|
||||
http://www.arduino.cc/en/Tutorial/SwitchCase
|
||||
*/
|
||||
|
||||
// these constants won't change:
|
||||
// these constants won't change. They are the
|
||||
// lowest and highest readings you get from your sensor:
|
||||
const int sensorMin = 0; // sensor minimum, discovered through experiment
|
||||
const int sensorMax = 600; // sensor maximum, discovered through experiment
|
||||
|
||||
@ -53,7 +54,7 @@ void loop() {
|
||||
Serial.println("bright");
|
||||
break;
|
||||
}
|
||||
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed fo Leonardo only
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
|
Loading…
x
Reference in New Issue
Block a user