Skip to content

Commit 47d3b65

Browse files
committed
Changed analog references to use new A0 through A5 notation
1 parent 5e2f82b commit 47d3b65

File tree

25 files changed

+57
-46
lines changed

25 files changed

+57
-46
lines changed

build/shared/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.pde

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ void setup() {
1010
}
1111

1212
void loop() {
13-
int sensorValue = analogRead(0);
13+
int sensorValue = analogRead(A0);
1414
Serial.println(sensorValue, DEC);
1515
}

build/shared/examples/1.Basics/Blink/Blink.pde

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
*/
77

88
void setup() {
9-
// initialize the digital pin as an output:
9+
// initialize the digital pin as an output.
10+
// Pin 13 has an LED connected on most Arduino boards:
1011
pinMode(13, OUTPUT);
1112
}
1213

build/shared/examples/2.Digital/toneKeyboard/toneKeyboard.pde

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* 8-ohm speaker on digital pin 8
1010
1111
created 21 Jan 2010
12+
Modified 4 Sep 2010
1213
by Tom Igoe
1314
1415
This example code is in the public domain.

build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.pde

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* 4.7K resistor on analog 0 to ground
1010
1111
created 21 Jan 2010
12+
Modified 4 Sep 2010
1213
by Tom Igoe
1314
1415
This example code is in the public domain.
@@ -25,7 +26,7 @@ void setup() {
2526

2627
void loop() {
2728
// read the sensor:
28-
int sensorReading = analogRead(0);
29+
int sensorReading = analogRead(A0);
2930
// print the sensor reading so you know its range
3031
Serial.println(sensorReading);
3132
// map the pitch to the range of the analog input.

build/shared/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.pde

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* LED connected from digital pin 9 to ground
1313
1414
created 29 Dec. 2008
15+
Modified 4 Sep 2010
1516
by Tom Igoe
1617
1718
This example code is in the public domain.
@@ -20,7 +21,7 @@
2021

2122
// These constants won't change. They're used to give names
2223
// to the pins used:
23-
const int analogInPin = 0; // Analog input pin that the potentiometer is attached to
24+
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
2425
const int analogOutPin = 9; // Analog output pin that the LED is attached to
2526

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

build/shared/examples/3.Analog/AnalogInSerial/AnalogInSerial.pde

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
void loop() {
2424
// read the analog input into a variable:
25-
int analogValue = analogRead(0);
25+
int analogValue = analogRead(A0);
2626
// print the result:
2727
Serial.println(analogValue);
2828
// wait 10 milliseconds for the analog-to-digital converter

build/shared/examples/3.Analog/AnalogInput/AnalogInput.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
2020
Created by David Cuartielles
21-
Modified 16 Jun 2009
21+
Modified 4 Sep 2010
2222
By Tom Igoe
2323
2424
This example code is in the public domain.
@@ -27,7 +27,7 @@
2727
2828
*/
2929

30-
int sensorPin = 0; // select the input pin for the potentiometer
30+
int sensorPin = A0; // select the input pin for the potentiometer
3131
int ledPin = 13; // select the pin for the LED
3232
int sensorValue = 0; // variable to store the value coming from the sensor
3333

build/shared/examples/3.Analog/Calibration/Calibration.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
created 29 Oct 2008
1919
By David A Mellis
20-
Modified 17 Jun 2009
20+
Modified 4 Sep 2010
2121
By Tom Igoe
2222
2323
http://arduino.cc/en/Tutorial/Calibration
@@ -27,7 +27,7 @@
2727
*/
2828

2929
// These constants won't change:
30-
const int sensorPin = 0; // pin that the sensor is attached to
30+
const int sensorPin = A0; // pin that the sensor is attached to
3131
const int ledPin = 9; // pin that the LED is attached to
3232

3333
// variables:

build/shared/examples/3.Analog/Smoothing/Smoothing.pde

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int index = 0; // the index of the current reading
3131
int total = 0; // the running total
3232
int average = 0; // the average
3333

34-
int inputPin = 0;
34+
int inputPin = A0;
3535

3636
void setup()
3737
{

build/shared/examples/4.Communication/Graph/Graph.pde

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void setup() {
3333

3434
void loop() {
3535
// send the value of analog input 0:
36-
Serial.println(analogRead(0));
36+
Serial.println(analogRead(A0));
3737
// wait a bit for the analog-to-digital converter
3838
// to stabilize after the last reading:
3939
delay(10);

build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
Created 26 Sept. 2005
1717
by Tom Igoe
18-
Modified 14 April 2009
18+
Modified 4 Sep 2010
1919
by Tom Igoe and Scott Fitzgerald
2020
2121
This example code is in the public domain.
@@ -44,7 +44,7 @@ void loop()
4444
// get incoming byte:
4545
inByte = Serial.read();
4646
// read first analog input, divide by 4 to make the range 0-255:
47-
firstSensor = analogRead(0)/4;
47+
firstSensor = analogRead(A0)/4;
4848
// delay 10ms to let the ADC recover:
4949
delay(10);
5050
// read second analog input, divide by 4 to make the range 0-255:

build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
Created 26 Sept. 2005
2121
by Tom Igoe
22-
Modified 14 April 2009
22+
Modified 4 Sep 2010
2323
by Tom Igoe and Scott Fitzgerald
2424
2525
This example code is in the public domain.
@@ -48,7 +48,7 @@ void loop()
4848
// get incoming byte:
4949
inByte = Serial.read();
5050
// read first analog input, divide by 4 to make the range 0-255:
51-
firstSensor = analogRead(0)/4;
51+
firstSensor = analogRead(A0)/4;
5252
// delay 10ms to let the ADC recover:
5353
delay(10);
5454
// read second analog input, divide by 4 to make the range 0-255:

build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
1111
created 2 Dec 2006
1212
by David A. Mellis
13-
modified 14 Apr 2009
13+
modified 4 Sep 2010
1414
by Tom Igoe and Scott Fitzgerald
1515
1616
This example code is in the public domain.
1717
*/
1818

19-
const int redPin = 0; // sensor to control red color
20-
const int greenPin = 1; // sensor to control green color
21-
const int bluePin = 2; // sensor to control blue color
19+
const int redPin = A0; // sensor to control red color
20+
const int greenPin = A1; // sensor to control green color
21+
const int bluePin = A2; // sensor to control blue color
2222

2323
void setup()
2424
{

build/shared/examples/5.Control/IfStatementConditional/IfStatementConditional.pde

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
connected to pin 13, so you don't need any extra components for this example.
1717
1818
created 17 Jan 2009
19+
modified 4 Sep 2010
1920
by Tom Igoe
2021
2122
This example code is in the public domain.
@@ -25,7 +26,7 @@ http://arduino.cc/en/Tutorial/IfStatement
2526
*/
2627

2728
// These constants won't change:
28-
const int analogPin = 0; // pin that the sensor is attached to
29+
const int analogPin = A0; // pin that the sensor is attached to
2930
const int ledPin = 13; // pin that the LED is attached to
3031
const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input
3132

build/shared/examples/5.Control/WhileStatementConditional/WhileStatementConditional.pde

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* 10K resistor attached from pin 2 to ground
1818
1919
created 17 Jan 2009
20-
modified 25 Jun 2009
20+
modified 4 Sep 2010
2121
by Tom Igoe
2222
2323
This example code is in the public domain.
@@ -28,10 +28,10 @@
2828

2929

3030
// These constants won't change:
31-
const int sensorPin = 2; // pin that the sensor is attached to
32-
const int ledPin = 9; // pin that the LED is attached to
33-
const int indicatorLedPin = 13; // pin that the built-in LED is attached to
34-
const int buttonPin = 2; // pin that the button is attached to
31+
const int sensorPin = A2; // pin that the sensor is attached to
32+
const int ledPin = 9; // pin that the LED is attached to
33+
const int indicatorLedPin = 13; // pin that the built-in LED is attached to
34+
const int buttonPin = 2; // pin that the button is attached to
3535

3636

3737
// These variables will change:

build/shared/examples/5.Control/switchCase/switchCase.pde

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* 10K resistor from analog in 0 to ground
1515
1616
created 1 Jul 2009
17+
modified 4 Sep 2010
1718
by Tom Igoe
1819
1920
This example code is in the public domain.
@@ -32,7 +33,7 @@ void setup() {
3233

3334
void loop() {
3435
// read the sensor:
35-
int sensorReading = analogRead(0);
36+
int sensorReading = analogRead(A0);
3637
// map the sensor range to a range of four options:
3738
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
3839

build/shared/examples/6.Sensors/ADXL3xx/ADXL3xx.pde

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
created 2 Jul 2008
2121
by David A. Mellis
22-
modified 26 Jun 2009
22+
modified 4 Sep 2010
2323
by Tom Igoe
2424
2525
This example code is in the public domain.
@@ -29,9 +29,9 @@
2929
// these constants describe the pins. They won't change:
3030
const int groundpin = 18; // analog input pin 4 -- ground
3131
const int powerpin = 19; // analog input pin 5 -- voltage
32-
const int xpin = 3; // x-axis of the accelerometer
33-
const int ypin = 2; // y-axis
34-
const int zpin = 1; // z-axis (only on 3-axis models)
32+
const int xpin = A3; // x-axis of the accelerometer
33+
const int ypin = A2; // y-axis
34+
const int zpin = A1; // z-axis (only on 3-axis models)
3535

3636
void setup()
3737
{

build/shared/examples/6.Sensors/Knock/Knock.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
created 25 Mar 2007
1616
by David Cuartielles <http://www.0j0.org>
17-
modified 30 Jun 2009
17+
modified 4 Sep 2010
1818
by Tom Igoe
1919
2020
This example code is in the public domain.
@@ -24,7 +24,7 @@
2424

2525
// these constants won't change:
2626
const int ledPin = 13; // led connected to digital pin 13
27-
const int knockSensor = 0; // the piezo is connected to analog pin 0
27+
const int knockSensor = A0; // the piezo is connected to analog pin 0
2828
const int threshold = 100; // threshold value to decide when the detected sound is a knock or not
2929

3030

build/shared/examples/7.Display/RowColumnScanning/RowColumnScanning.pde

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

build/shared/examples/7.Display/barGraph/barGraph.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
The circuit:
1313
* LEDs from pins 2 through 11 to ground
1414
15-
created 26 Jun 2009
15+
created 4 Sep 2010
1616
by Tom Igoe
1717
1818
This example code is in the public domain.
@@ -22,7 +22,7 @@
2222

2323

2424
// these constants won't change:
25-
const int analogPin = 0; // the pin that the potentiometer is attached to
25+
const int analogPin = A0; // the pin that the potentiometer is attached to
2626
const int ledCount = 10; // the number of LEDs in the bar graph
2727

2828
int ledPins[] = {

build/shared/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.pde

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
You can also add several different data types to string, as shown here:
66
77
created 27 July 2010
8+
modified 4 Sep 2010
89
by Tom Igoe
910
1011
http://arduino.cc/en/Tutorial/StringAdditionOperator
@@ -44,10 +45,10 @@ void loop() {
4445
Serial.println(stringThree); // prints "You added this string"
4546

4647
// adding a variable integer to a string:
47-
int sensorValue = analogRead(0);
48+
int sensorValue = analogRead(A0);
4849
stringOne = "Sensor value: ";
4950
stringThree = stringOne + sensorValue;
50-
Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(0) has
51+
Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(A0) has
5152

5253
// adding a variable long integer to a string:
5354
long currentTime = millis();

build/shared/examples/8.Strings/StringAppendOperator/StringAppendOperator.pde

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Examples of how to append different data types to strings
55
66
created 27 July 2010
7+
modified 4 Sep 2010
78
by Tom Igoe
89
910
http://arduino.cc/en/Tutorial/StringAppendOperator
@@ -43,8 +44,8 @@ void loop() {
4344
Serial.println(stringOne); // prints "Sensor value for input"
4445

4546
// adding a variable integer to a string:
46-
stringOne += analogRead(0);
47-
Serial.println(stringOne); // prints "Sensor value for input A0: 456" or whatever analogRead(0) is
47+
stringOne += analogRead(A0);
48+
Serial.println(stringOne); // prints "Sensor value for input A0: 456" or whatever analogRead(A0) is
4849

4950
Serial.println("\n\nchanging the Strings' values");
5051
stringOne = "A long integer: ";

build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Examples of how to compare strings using the comparison operators
55
66
created 27 July 2010
7+
modified 4 Sep 2010
78
by Tom Igoe
89
910
http://arduino.cc/en/Tutorial/StringComparisonOperators
@@ -109,8 +110,8 @@ void loop() {
109110
stringOne = "Sensor: ";
110111
stringTwo= "Sensor: ";
111112

112-
stringOne += analogRead(0);
113-
stringTwo += analogRead(5);
113+
stringOne += analogRead(A0);
114+
stringTwo += analogRead(A5);
114115

115116
if (stringOne.compareTo(stringTwo) < 0 ) {
116117
Serial.println(stringOne + " comes after " + stringTwo);

build/shared/examples/8.Strings/StringConstructors/StringConstructors.pde

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Examples of how to create strings from other data types
55
66
created 27 July 2010
7+
modified 4 Sep 2010
78
by Tom Igoe
89
910
http://arduino.cc/en/Tutorial/StringConstructors
@@ -38,8 +39,8 @@ void loop() {
3839
Serial.println(stringOne); // prints "13"
3940

4041
// using an int and a base:
41-
stringOne = String(analogRead(0), DEC);
42-
// prints "453" or whatever the value of analogRead(0) is
42+
stringOne = String(analogRead(A0), DEC);
43+
// prints "453" or whatever the value of analogRead(A0) is
4344
Serial.println(stringOne);
4445

4546
// using an int and a base (hexadecimal):

0 commit comments

Comments
 (0)