Skip to content

Commit c44329d

Browse files
committed
Merge branch 'master' of github.com:arduino/Arduino into LUFA_bootloader
Conflicts: build/shared/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino
2 parents 9adcdad + 4b886ef commit c44329d

File tree

5 files changed

+60
-14
lines changed

5 files changed

+60
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
/*
22
AnalogReadSerial
3-
Reads an analog input on pin 0, prints the result to the serial monitor
3+
Reads an analog input on pin 0, prints the result to the serial monitor.
4+
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
45
56
This example code is in the public domain.
67
*/
78

9+
// the setup routine runs once when you press reset:
810
void setup() {
11+
// initialize serial communication at 9600 bits per second:
912
Serial.begin(9600);
1013
}
1114

15+
// the loop routine runs over and over again forever:
1216
void loop() {
17+
// read the input on analog pin 0:
1318
int sensorValue = analogRead(A0);
19+
// print out the value you read:
1420
Serial.println(sensorValue);
1521
delay(1); // delay in between reads for stability
1622
}

build/shared/examples/01.Basics/Blink/Blink.ino

+11-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44
55
This example code is in the public domain.
66
*/
7+
8+
// Pin 13 has an LED connected on most Arduino boards.
9+
// give it a name:
10+
int led = 13;
711

12+
// the setup routine runs once when you press reset:
813
void setup() {
914
// initialize the digital pin as an output.
10-
// Pin 13 has an LED connected on most Arduino boards:
11-
pinMode(13, OUTPUT);
15+
pinMode(led, OUTPUT);
1216
}
1317

18+
// the loop routine runs over and over again forever:
1419
void loop() {
15-
digitalWrite(13, HIGH); // set the LED on
16-
delay(1000); // wait for a second
17-
digitalWrite(13, LOW); // set the LED off
18-
delay(1000); // wait for a second
20+
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
21+
delay(1000); // wait for a second
22+
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
23+
delay(1000); // wait for a second
1924
}

build/shared/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino

+12-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@
55
This example code is in the public domain.
66
*/
77

8+
// digital pin 2 has a pushbutton attached to it. Give it a name:
9+
int pushButton = 2;
10+
11+
// the setup routine runs once when you press reset:
812
void setup() {
13+
// initialize serial communication at 9600 bits per second:
914
Serial.begin(9600);
10-
pinMode(2, INPUT);
15+
// make the pushbutton's pin an input:
16+
pinMode(pushButton, INPUT);
1117
}
1218

19+
// the loop routine runs over and over again forever:
1320
void loop() {
14-
int sensorValue = digitalRead(2);
15-
Serial.println(sensorValue);
16-
delay(1); // short delay in between reads for stability
21+
// read the input pin:
22+
int buttonState = digitalRead(pushButton);
23+
// print out the state of the button:
24+
Serial.println(buttonState);
1725
}
1826

1927

build/shared/examples/01.Basics/Fade/Fade.ino

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
using the analogWrite() function.
66
77
This example code is in the public domain.
8-
98
*/
9+
10+
int led = 9; // the pin that the LED is attached to
1011
int brightness = 0; // how bright the LED is
1112
int fadeAmount = 5; // how many points to fade the LED by
1213

14+
// the setup routine runs once when you press reset:
1315
void setup() {
1416
// declare pin 9 to be an output:
15-
pinMode(9, OUTPUT);
17+
pinMode(led, OUTPUT);
1618
}
1719

20+
// the loop routine runs over and over again forever:
1821
void loop() {
1922
// set the brightness of pin 9:
20-
analogWrite(9, brightness);
23+
analogWrite(led, brightness);
2124

2225
// change the brightness for next time through the loop:
2326
brightness = brightness + fadeAmount;
@@ -29,3 +32,4 @@ void loop() {
2932
// wait for 30 milliseconds to see the dimming effect
3033
delay(30);
3134
}
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
ReadAnalogVoltage
3+
Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
4+
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
5+
6+
This example code is in the public domain.
7+
*/
8+
9+
// the setup routine runs once when you press reset:
10+
void setup() {
11+
// initialize serial communication at 9600 bits per second:
12+
Serial.begin(9600);
13+
}
14+
15+
// the loop routine runs over and over again forever:
16+
void loop() {
17+
// read the input on analog pin 0:
18+
int sensorValue = analogRead(A0);
19+
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
20+
float voltage = sensorValue * (5.0 / 1023.0);
21+
// print out the value you read:
22+
Serial.println(voltage);
23+
}

0 commit comments

Comments
 (0)