Skip to content

Commit a0f1f1a

Browse files
committed
Merge branch 'master' of github.com:arduino/Arduino into LUFA_bootloader
2 parents f5093b0 + 19f513b commit a0f1f1a

File tree

7 files changed

+136
-48
lines changed

7 files changed

+136
-48
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Input Pullup Serial
3+
4+
This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a
5+
digital input on pin 2 and prints the results to the serial monitor.
6+
7+
The circuit:
8+
* Momentary switch attached from pin 2 to ground
9+
* Built-in LED on pin 13
10+
11+
Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
12+
20K-ohm resistor is pulled to 5V. This configuration causes the input to
13+
read HIGH when the switch is open, and LOW when it is closed.
14+
15+
created 14 March 2012
16+
by Scott Fitzgerald
17+
18+
http://www.arduino.cc/en/Tutorial/InputPullupSerial
19+
20+
This example code is in the public domain
21+
22+
*/
23+
24+
void setup(){
25+
//start serial connection
26+
Serial.begin(9600);
27+
//configure pin2 as an input and enable the internal pull-up resistor
28+
pinMode(2, INPUT_PULLUP);
29+
pinMode(13, OUTPUT);
30+
31+
}
32+
33+
void loop(){
34+
//read the pushbutton value into a variable
35+
int sensorVal = digitalRead(2);
36+
//print out the value of the pushbutton
37+
Serial.println(sensorVal);
38+
39+
// Keep in mind the pullup means the pushbutton's
40+
// logic is inverted. It goes HIGH when it's open,
41+
// and LOW when it's pressed. Turn on pin 13 when the
42+
// button's pressed, and off when it's not:
43+
if (sensorVal == HIGH) {
44+
digitalWrite(13, LOW);
45+
}
46+
else {
47+
digitalWrite(13, HIGH);
48+
}
49+
}
50+
51+
52+

build/shared/examples/ArduinoISP/ArduinoISP.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
void pulse(int pin, int times);
6767

6868
void setup() {
69-
Serial.begin(9600);
69+
Serial.begin(19200);
7070
pinMode(LED_PMODE, OUTPUT);
7171
pulse(LED_PMODE, 2);
7272
pinMode(LED_ERR, OUTPUT);
@@ -109,7 +109,7 @@ void heartbeat() {
109109
if (hbval < 32) hbdelta = -hbdelta;
110110
hbval += hbdelta;
111111
analogWrite(LED_HB, hbval);
112-
delay(40);
112+
delay(20);
113113
}
114114

115115

hardware/arduino/programmers.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ parallel.force=true
2323
arduinoisp.name=Arduino as ISP
2424
arduinoisp.communication=serial
2525
arduinoisp.protocol=stk500v1
26-
arduinoisp.speed=9600
26+
arduinoisp.speed=19200

libraries/Ethernet/examples/PachubeClient/PachubeClient.ino

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Ethernet shield attached to pins 10, 11, 12, 13
1717
1818
created 15 March 2010
19-
updated 27 Feb 2012
19+
updated 16 Mar 2012
2020
by Tom Igoe with input from Usman Haque and Joe Saavedra
2121
2222
http://arduino.cc/en/Tutorial/PachubeClient
@@ -27,8 +27,6 @@ http://arduino.cc/en/Tutorial/PachubeClient
2727
#include <SPI.h>
2828
#include <Ethernet.h>
2929

30-
31-
3230
#define APIKEY "YOUR API KEY GOES HERE" // replace your pachube api key here
3331
#define FEEDID 00000 // replace your feed ID
3432
#define USERAGENT "My Project" // user agent is the project name
@@ -45,9 +43,14 @@ IPAddress ip(10,0,1,20);
4543
// initialize the library instance:
4644
EthernetClient client;
4745

48-
long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
49-
boolean lastConnected = false; // state of the connection last time through the main loop
50-
const int postingInterval = 10000; //delay between updates to Pachube.com
46+
// if you don't want to use DNS (and reduce your sketch size)
47+
// use the numeric IP instead of the name for the server:
48+
IPAddress server(216,52,233,122); // numeric IP for api.pachube.com
49+
//char server[] = "api.pachube.com"; // name address for pachube API
50+
51+
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
52+
boolean lastConnected = false; // state of the connection last time through the main loop
53+
const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com
5154

5255
void setup() {
5356
// start serial port:
@@ -93,13 +96,13 @@ void loop() {
9396
// this method makes a HTTP connection to the server:
9497
void sendData(int thisData) {
9598
// if there's a successful connection:
96-
if (client.connect("www.pachube.com", 80)) {
99+
if (client.connect(server, 80)) {
97100
Serial.println("connecting...");
98-
// send the HTTP PUT request:
101+
// send the HTTP PUT request:
99102
client.print("PUT /v2/feeds/");
100103
client.print(FEEDID);
101104
client.println(".csv HTTP/1.1");
102-
client.print("Host: api.pachube.com\n");
105+
client.println("Host: api.pachube.com");
103106
client.print("X-PachubeApiKey: ");
104107
client.println(APIKEY);
105108
client.print("User-Agent: ");
@@ -112,24 +115,24 @@ void sendData(int thisData) {
112115
client.println(thisLength);
113116

114117
// last pieces of the HTTP PUT request:
115-
client.print("Content-Type: text/csv\n");
116-
client.println("Connection: close\n");
118+
client.println("Content-Type: text/csv");
119+
client.println("Connection: close");
120+
client.println();
117121

118122
// here's the actual content of the PUT request:
119-
client.print("sensor1,");
123+
client.print("sensor1,");
120124
client.println(thisData);
121-
122-
// note the time that the connection was made:
123-
lastConnectionTime = millis();
125+
124126
}
125127
else {
126-
// if you couldn't make a connection:
128+
// if you couldn't make a connection:
127129
Serial.println("connection failed");
128130
Serial.println();
129131
Serial.println("disconnecting.");
130132
client.stop();
131-
lastConnected = client.connected();
132133
}
134+
// note the time that the connection was made or attempted:
135+
lastConnectionTime = millis();
133136
}
134137

135138

libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Ethernet shield attached to pins 10, 11, 12, 13
1919
2020
created 15 March 2010
21-
updated 27 Feb 2012
21+
updated 16 Mar 2012
2222
by Tom Igoe with input from Usman Haque and Joe Saavedra
2323
2424
http://arduino.cc/en/Tutorial/PachubeClientString
@@ -40,14 +40,19 @@
4040
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
4141
// fill in an available IP address on your network here,
4242
// for manual configuration:
43-
IPAddress ip(10,0,0,20);
43+
IPAddress ip(10,0,1,20);
4444

4545
// initialize the library instance:
4646
EthernetClient client;
4747

48-
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
49-
boolean lastConnected = false; // state of the connection last time through the main loop
50-
const unsigned long postingInterval = 10000; //delay between updates to Pachube.com
48+
// if you don't want to use DNS (and reduce your sketch size)
49+
// use the numeric IP instead of the name for the server:
50+
//IPAddress server(216,52,233,122); // numeric IP for api.pachube.com
51+
char server[] = "api.pachube.com"; // name address for pachube API
52+
53+
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
54+
boolean lastConnected = false; // state of the connection last time through the main loop
55+
const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com
5156

5257
void setup() {
5358
// start serial port:
@@ -66,9 +71,9 @@ void loop() {
6671
// read the analog sensor:
6772
int sensorReading = analogRead(A0);
6873
// convert the data to a String to send it:
69-
74+
7075
String dataString = "sensor1,";
71-
dataString += sensorReading;
76+
dataString += sensorReading;
7277

7378
// you can append multiple readings to this String if your
7479
// pachube feed is set up to handle multiple values:
@@ -93,7 +98,7 @@ void loop() {
9398
}
9499

95100
// if you're not connected, and ten seconds have passed since
96-
// your last connection, then connect again and send data:
101+
// your last connection, then connect again and send data:
97102
if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
98103
sendData(dataString);
99104
}
@@ -105,38 +110,36 @@ void loop() {
105110
// this method makes a HTTP connection to the server:
106111
void sendData(String thisData) {
107112
// if there's a successful connection:
108-
if (client.connect("api.pachube.com", 80)) {
113+
if (client.connect(server, 80)) {
109114
Serial.println("connecting...");
110115
// send the HTTP PUT request:
111116
client.print("PUT /v2/feeds/");
112117
client.print(FEEDID);
113118
client.println(".csv HTTP/1.1");
114-
client.print("Host: api.pachube.com\n");
119+
client.println("Host: api.pachube.com");
115120
client.print("X-PachubeApiKey: ");
116121
client.println(APIKEY);
117122
client.print("User-Agent: ");
118123
client.println(USERAGENT);
119124
client.print("Content-Length: ");
120-
client.println(thisData.length(), DEC);
125+
client.println(thisData.length());
121126

122127
// last pieces of the HTTP PUT request:
123-
client.print("Content-Type: text/csv\n");
124-
client.println("Connection: close\n");
128+
client.println("Content-Type: text/csv");
129+
client.println("Connection: close");
130+
client.println();
125131

126132
// here's the actual content of the PUT request:
127133
client.println(thisData);
128-
129-
// note the time that the connection was made:
130-
lastConnectionTime = millis();
131134
}
132135
else {
133136
// if you couldn't make a connection:
134137
Serial.println("connection failed");
135138
Serial.println();
136139
Serial.println("disconnecting.");
137140
client.stop();
138-
lastConnected = client.connected();
139141
}
142+
// note the time that the connection was made or attempted:
143+
lastConnectionTime = millis();
140144
}
141145

142-

libraries/Ethernet/examples/WebServer/WebServer.ino

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
created 18 Dec 2009
1212
by David A. Mellis
13-
modified 4 Sep 2010
13+
modified 20 Mar 2012
1414
by Tom Igoe
1515
1616
*/
@@ -20,48 +20,59 @@
2020

2121
// Enter a MAC address and IP address for your controller below.
2222
// The IP address will be dependent on your local network:
23-
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
23+
byte mac[] = {
24+
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
2425
IPAddress ip(192,168,1, 177);
2526

2627
// Initialize the Ethernet server library
2728
// with the IP address and port you want to use
2829
// (port 80 is default for HTTP):
2930
EthernetServer server(80);
3031

31-
void setup()
32-
{
32+
void setup() {
33+
Serial.begin(9600);
3334
// start the Ethernet connection and the server:
3435
Ethernet.begin(mac, ip);
3536
server.begin();
37+
Serial.print("server is at ");
38+
Serial.println(Ethernet.localIP());
3639
}
3740

38-
void loop()
39-
{
41+
42+
void loop() {
4043
// listen for incoming clients
4144
EthernetClient client = server.available();
4245
if (client) {
46+
Serial.println("new client");
4347
// an http request ends with a blank line
4448
boolean currentLineIsBlank = true;
4549
while (client.connected()) {
4650
if (client.available()) {
4751
char c = client.read();
52+
Serial.write(c);
4853
// if you've gotten to the end of the line (received a newline
4954
// character) and the line is blank, the http request has ended,
5055
// so you can send a reply
5156
if (c == '\n' && currentLineIsBlank) {
5257
// send a standard http response header
5358
client.println("HTTP/1.1 200 OK");
5459
client.println("Content-Type: text/html");
60+
client.println("Connnection: close");
5561
client.println();
56-
62+
client.println("<!DOCTYPE HTML>");
63+
client.println("<html>");
64+
// add a meta refresh tag, so the browser pulls again every 5 seconds:
65+
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
5766
// output the value of each analog input pin
5867
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
68+
int sensorReading = analogRead(analogChannel);
5969
client.print("analog input ");
6070
client.print(analogChannel);
6171
client.print(" is ");
62-
client.print(analogRead(analogChannel));
63-
client.println("<br />");
72+
client.print(sensorReading);
73+
client.println("<br />");
6474
}
75+
client.println("</html>");
6576
break;
6677
}
6778
if (c == '\n') {
@@ -78,5 +89,7 @@ void loop()
7889
delay(1);
7990
// close the connection:
8091
client.stop();
92+
Serial.println("client disonnected");
8193
}
8294
}
95+

libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
/*
2+
Software serial multple serial test
3+
4+
Receives from the hardware serial, sends to software serial.
5+
Receives from software serial, sends to hardware serial.
6+
7+
The circuit:
8+
* RX is digital pin 2 (connect to TX of other device)
9+
* TX is digital pin 3 (connect to RX of other device)
10+
11+
created back in the mists of time
12+
by Tom Igoe
13+
based on Mikal Hart's example
14+
15+
This example code is in the public domain.
16+
17+
*/
118
#include <SoftwareSerial.h>
219

3-
SoftwareSerial mySerial(2, 3);
20+
SoftwareSerial mySerial(2, 3); // RX, TX
421

522
void setup()
623
{

0 commit comments

Comments
 (0)