Changed analog references to use new A0 through A5 notation

This commit is contained in:
Tom Igoe 2010-09-04 19:47:59 +00:00
parent 5e2f82b742
commit 47d3b65e51
25 changed files with 57 additions and 46 deletions

View File

@ -10,6 +10,6 @@ void setup() {
}
void loop() {
int sensorValue = analogRead(0);
int sensorValue = analogRead(A0);
Serial.println(sensorValue, DEC);
}

View File

@ -6,7 +6,8 @@
*/
void setup() {
// initialize the digital pin as an output:
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}

View File

@ -9,6 +9,7 @@
* 8-ohm speaker on digital pin 8
created 21 Jan 2010
Modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.

View File

@ -9,6 +9,7 @@
* 4.7K resistor on analog 0 to ground
created 21 Jan 2010
Modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
@ -25,7 +26,7 @@ void setup() {
void loop() {
// read the sensor:
int sensorReading = analogRead(0);
int sensorReading = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorReading);
// map the pitch to the range of the analog input.

View File

@ -12,6 +12,7 @@
* LED connected from digital pin 9 to ground
created 29 Dec. 2008
Modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
@ -20,7 +21,7 @@
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = 0; // Analog input pin that the potentiometer is attached to
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot

View File

@ -22,7 +22,7 @@
void loop() {
// read the analog input into a variable:
int analogValue = analogRead(0);
int analogValue = analogRead(A0);
// print the result:
Serial.println(analogValue);
// wait 10 milliseconds for the analog-to-digital converter

View File

@ -18,7 +18,7 @@
Created by David Cuartielles
Modified 16 Jun 2009
Modified 4 Sep 2010
By Tom Igoe
This example code is in the public domain.
@ -27,7 +27,7 @@
*/
int sensorPin = 0; // select the input pin for the potentiometer
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor

View File

@ -17,7 +17,7 @@
created 29 Oct 2008
By David A Mellis
Modified 17 Jun 2009
Modified 4 Sep 2010
By Tom Igoe
http://arduino.cc/en/Tutorial/Calibration
@ -27,7 +27,7 @@
*/
// These constants won't change:
const int sensorPin = 0; // 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:

View File

@ -31,7 +31,7 @@ int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
int inputPin = 0;
int inputPin = A0;
void setup()
{

View File

@ -33,7 +33,7 @@ void setup() {
void loop() {
// send the value of analog input 0:
Serial.println(analogRead(0));
Serial.println(analogRead(A0));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(10);

View File

@ -15,7 +15,7 @@
Created 26 Sept. 2005
by Tom Igoe
Modified 14 April 2009
Modified 4 Sep 2010
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
@ -44,7 +44,7 @@ void loop()
// get incoming byte:
inByte = Serial.read();
// read first analog input, divide by 4 to make the range 0-255:
firstSensor = analogRead(0)/4;
firstSensor = analogRead(A0)/4;
// delay 10ms to let the ADC recover:
delay(10);
// read second analog input, divide by 4 to make the range 0-255:

View File

@ -19,7 +19,7 @@
Created 26 Sept. 2005
by Tom Igoe
Modified 14 April 2009
Modified 4 Sep 2010
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
@ -48,7 +48,7 @@ void loop()
// get incoming byte:
inByte = Serial.read();
// read first analog input, divide by 4 to make the range 0-255:
firstSensor = analogRead(0)/4;
firstSensor = analogRead(A0)/4;
// delay 10ms to let the ADC recover:
delay(10);
// read second analog input, divide by 4 to make the range 0-255:

View File

@ -10,15 +10,15 @@
created 2 Dec 2006
by David A. Mellis
modified 14 Apr 2009
modified 4 Sep 2010
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
*/
const int redPin = 0; // sensor to control red color
const int greenPin = 1; // sensor to control green color
const int bluePin = 2; // sensor to control blue color
const int redPin = A0; // sensor to control red color
const int greenPin = A1; // sensor to control green color
const int bluePin = A2; // sensor to control blue color
void setup()
{

View File

@ -16,6 +16,7 @@
connected to pin 13, so you don't need any extra components for this example.
created 17 Jan 2009
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
@ -25,7 +26,7 @@ http://arduino.cc/en/Tutorial/IfStatement
*/
// These constants won't change:
const int analogPin = 0; // pin that the sensor is attached to
const int analogPin = A0; // pin that the sensor is attached to
const int ledPin = 13; // pin that the LED is attached to
const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input

View File

@ -17,7 +17,7 @@
* 10K resistor attached from pin 2 to ground
created 17 Jan 2009
modified 25 Jun 2009
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
@ -28,10 +28,10 @@
// These constants won't change:
const int sensorPin = 2; // pin that the sensor is attached to
const int ledPin = 9; // pin that the LED is attached to
const int indicatorLedPin = 13; // pin that the built-in LED is attached to
const int buttonPin = 2; // pin that the button is attached to
const int sensorPin = A2; // pin that the sensor is attached to
const int ledPin = 9; // pin that the LED is attached to
const int indicatorLedPin = 13; // pin that the built-in LED is attached to
const int buttonPin = 2; // pin that the button is attached to
// These variables will change:

View File

@ -14,6 +14,7 @@
* 10K resistor from analog in 0 to ground
created 1 Jul 2009
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
@ -32,7 +33,7 @@ void setup() {
void loop() {
// read the sensor:
int sensorReading = analogRead(0);
int sensorReading = analogRead(A0);
// map the sensor range to a range of four options:
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);

View File

@ -19,7 +19,7 @@
created 2 Jul 2008
by David A. Mellis
modified 26 Jun 2009
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
@ -29,9 +29,9 @@
// these constants describe the pins. They won't change:
const int groundpin = 18; // analog input pin 4 -- ground
const int powerpin = 19; // analog input pin 5 -- voltage
const int xpin = 3; // x-axis of the accelerometer
const int ypin = 2; // y-axis
const int zpin = 1; // z-axis (only on 3-axis models)
const int xpin = A3; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
void setup()
{

View File

@ -14,7 +14,7 @@
created 25 Mar 2007
by David Cuartielles <http://www.0j0.org>
modified 30 Jun 2009
modified 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
@ -24,7 +24,7 @@
// these constants won't change:
const int ledPin = 13; // led connected to digital pin 13
const int knockSensor = 0; // the piezo is connected to analog pin 0
const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 100; // threshold value to decide when the detected sound is a knock or not

View File

@ -4,7 +4,7 @@
This example controls an 8x8 LED matrix using two analog inputs
created 27 May 2009
modified 29 Jun 2009
modified 4 Sep 2010
by Tom Igoe
This example works for the Lumex LDM-24488NI Matrix. See
@ -83,8 +83,8 @@ void readSensors() {
// turn off the last position:
pixels[x][y] = HIGH;
// read the sensors for X and Y values:
x = 7 - map(analogRead(0), 0, 1023, 0, 7);
y = map(analogRead(1), 0, 1023, 0, 7);
x = 7 - map(analogRead(A0), 0, 1023, 0, 7);
y = map(analogRead(A1), 0, 1023, 0, 7);
// set the new pixel position low so that the LED will turn on
// in the next screen refresh:
pixels[x][y] = LOW;

View File

@ -12,7 +12,7 @@
The circuit:
* LEDs from pins 2 through 11 to ground
created 26 Jun 2009
created 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
@ -22,7 +22,7 @@
// these constants won't change:
const int analogPin = 0; // the pin that the potentiometer is attached to
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 10; // the number of LEDs in the bar graph
int ledPins[] = {

View File

@ -5,6 +5,7 @@
You can also add several different data types to string, as shown here:
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringAdditionOperator
@ -44,10 +45,10 @@ void loop() {
Serial.println(stringThree); // prints "You added this string"
// adding a variable integer to a string:
int sensorValue = analogRead(0);
int sensorValue = analogRead(A0);
stringOne = "Sensor value: ";
stringThree = stringOne + sensorValue;
Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(0) has
Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(A0) has
// adding a variable long integer to a string:
long currentTime = millis();

View File

@ -4,6 +4,7 @@
Examples of how to append different data types to strings
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringAppendOperator
@ -43,8 +44,8 @@ void loop() {
Serial.println(stringOne); // prints "Sensor value for input"
// adding a variable integer to a string:
stringOne += analogRead(0);
Serial.println(stringOne); // prints "Sensor value for input A0: 456" or whatever analogRead(0) is
stringOne += analogRead(A0);
Serial.println(stringOne); // prints "Sensor value for input A0: 456" or whatever analogRead(A0) is
Serial.println("\n\nchanging the Strings' values");
stringOne = "A long integer: ";

View File

@ -4,6 +4,7 @@
Examples of how to compare strings using the comparison operators
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringComparisonOperators
@ -109,8 +110,8 @@ void loop() {
stringOne = "Sensor: ";
stringTwo= "Sensor: ";
stringOne += analogRead(0);
stringTwo += analogRead(5);
stringOne += analogRead(A0);
stringTwo += analogRead(A5);
if (stringOne.compareTo(stringTwo) < 0 ) {
Serial.println(stringOne + " comes after " + stringTwo);

View File

@ -4,6 +4,7 @@
Examples of how to create strings from other data types
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringConstructors
@ -38,8 +39,8 @@ void loop() {
Serial.println(stringOne); // prints "13"
// using an int and a base:
stringOne = String(analogRead(0), DEC);
// prints "453" or whatever the value of analogRead(0) is
stringOne = String(analogRead(A0), DEC);
// prints "453" or whatever the value of analogRead(A0) is
Serial.println(stringOne);
// using an int and a base (hexadecimal):

View File

@ -4,6 +4,7 @@
Examples of how to use startsWith() and endsWith() in a String
created 27 July 2010
modified 4 Sep 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringStartsWithEndsWith
@ -33,7 +34,7 @@ void loop() {
// endsWith() checks to see if a String ends with a particular character:
String sensorReading = "sensor = ";
sensorReading += analogRead(0);
sensorReading += analogRead(A0);
Serial.print (sensorReading);
if (sensorReading.endsWith(0)) {
Serial.println(". This reading is divisible by ten");