deleted redundant analog in example and corrected typos in comments for analog examples

This commit is contained in:
Tom Igoe 2010-09-17 16:43:22 +00:00
parent addbdd7949
commit bc2999f00d
2 changed files with 6 additions and 37 deletions

View File

@ -1,31 +0,0 @@
/*
Analog input, serial output
Reads an analog input pin, prints the results to the serial monitor.
The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
created over and over again
by Tom Igoe and everyone who's ever used Arduino
This example code is in the public domain. It's practically in the collective unconscious by now too.
*/
void setup() {
Serial.begin(9600);
}
void loop() {
// read the analog input into a variable:
int analogValue = analogRead(A0);
// print the result:
Serial.println(analogValue);
// wait 10 milliseconds for the analog-to-digital converter
// to settle after the last reading:
delay(10);
}

View File

@ -1,14 +1,14 @@
/*
Calibration
Demonstrates one techinque for calibrating sensor input. The
Demonstrates one technique for calibrating sensor input. The
sensor readings during the first five seconds of the sketch
execution define the minimum and maximum of expected values
attached to the sensor pin.
The sensor minumum and maximum initial values may seem backwards.
The sensor minimum and maximum initial values may seem backwards.
Initially, you set the minimum high and listen for anything
lower, saving it as the new minumum. Likewise, you set the
lower, saving it as the new minimum. Likewise, you set the
maximum low and listen for anything higher as the new maximum.
The circuit:
@ -27,13 +27,13 @@
*/
// These constants won't change:
const int sensorPin = A0; // pin that the sensor is attached to
const int sensorPin = A0; // pin that the sensor is attached to
const int ledPin = 9; // pin that the LED is attached to
// variables:
int sensorValue = 0; // the sensor value
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value
void setup() {