1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-19 09:42:11 +03:00

Merge of arduino-1.0.1. Work in progress...

This commit is contained in:
Cristian Maglie
2012-05-23 09:22:52 +02:00
215 changed files with 37716 additions and 6881 deletions

View File

@ -14,7 +14,11 @@ byte value;
void setup()
{
// initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
}
void loop()

View File

@ -12,7 +12,7 @@
created 18 Dec 2009
by David A. Mellis
modified 12 March 2012
modified 9 Apr 2012
by Tom Igoe
*/
@ -39,8 +39,13 @@ void setup() {
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
// open the serial port
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Chat server address:");
Serial.println(Ethernet.localIP());
}

View File

@ -9,6 +9,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 12 April 2011
modified 9 Apr 2012
by Tom Igoe
*/
@ -27,8 +28,13 @@ byte mac[] = {
EthernetClient client;
void setup() {
// start the serial library:
// Open serial communications and wait for port to open:
Serial.begin(9600);
// this check is only needed on the Leonardo:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -12,6 +12,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 21 May 2011
modified 9 Apr 2012
by Tom Igoe
Based on ChatServer example by David A. Mellis
@ -34,8 +35,14 @@ EthernetServer server(23);
boolean gotAMessage = false; // whether or not you got a message from the client yet
void setup() {
// open the serial port
// Open serial communications and wait for port to open:
Serial.begin(9600);
// this check is only needed on the Leonardo:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
Serial.println("Trying to get an IP address using DHCP");
if (Ethernet.begin(mac) == 0) {

View File

@ -9,7 +9,7 @@
created 18 Dec 2009
by David A. Mellis
modified 12 April 2011
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen
*/
@ -28,8 +28,13 @@ char serverName[] = "www.google.com";
EthernetClient client;
void setup() {
// start the serial library:
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -16,7 +16,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010
updated 16 Mar 2012
modified 9 Apr 2012
by Tom Igoe with input from Usman Haque and Joe Saavedra
http://arduino.cc/en/Tutorial/PachubeClient
@ -53,8 +53,13 @@ boolean lastConnected = false; // state of the connection last t
const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com
void setup() {
// start serial port:
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -1,12 +1,12 @@
/*
Pachube sensor client with Strings
Cosm sensor client with Strings
This sketch connects an analog sensor to Pachube (http://www.pachube.com)
This sketch connects an analog sensor to Cosm (http://www.cosm.com)
using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
the Adafruit Ethernet shield, either one will work, as long as it's got
a Wiznet Ethernet module on board.
This example has been updated to use version 2.0 of the Pachube.com API.
This example has been updated to use version 2.0 of the Cosm.com API.
To make it work, create a feed with two datastreams, and give them the IDs
sensor1 and sensor2. Or change the code below to match your feed.
@ -18,10 +18,10 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010
updated 16 Mar 2012
modified 9 Apr 2012
by Tom Igoe with input from Usman Haque and Joe Saavedra
http://arduino.cc/en/Tutorial/PachubeClientString
http://arduino.cc/en/Tutorial/CosmClientString
This code is in the public domain.
*/
@ -30,14 +30,16 @@
#include <Ethernet.h>
#define APIKEY "YOUR API KEY GOES HERE" // replace your pachube api key here
/#define APIKEY "YOUR API KEY GOES HERE" // replace your Cosm api key here
#define FEEDID 00000 // replace your feed ID
#define USERAGENT "My Project" // user agent is the project name
// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(10,0,1,20);
@ -47,16 +49,21 @@ EthernetClient client;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(216,52,233,122); // numeric IP for api.pachube.com
char server[] = "api.pachube.com"; // name address for pachube API
IPAddress server(216,52,233,121); // numeric IP for api.cosm.com
//char server[] = "api.cosm.com"; // name address for Cosm API
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com
const unsigned long postingInterval = 10*1000; //delay between updates to Cosm.com
void setup() {
// start serial port:
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// give the ethernet module time to boot up:
delay(1000);
// start the Ethernet connection:
@ -76,7 +83,7 @@ void loop() {
dataString += sensorReading;
// you can append multiple readings to this String if your
// pachube feed is set up to handle multiple values:
// Cosm feed is set up to handle multiple values:
int otherSensorReading = analogRead(A1);
dataString += "\nsensor2,";
dataString += otherSensorReading;
@ -116,8 +123,8 @@ void sendData(String thisData) {
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.pachube.com");
client.print("X-PachubeApiKey: ");
client.println("Host: api.cosm.com");
client.print("X-CosmApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);

View File

@ -13,6 +13,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 14 Sep 2010
modified 9 Apr 2012
by Tom Igoe
*/
@ -38,8 +39,13 @@ EthernetClient client;
void setup() {
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// start the serial library:
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");

View File

@ -17,6 +17,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 21 May 2011
modified 9 Apr 2012
by Tom Igoe
This code is in the public domain.
@ -51,8 +52,13 @@ void setup() {
currentLine.reserve(256);
tweet.reserve(150);
// initialize serial:
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// attempt a DHCP connection:
Serial.println("Attempting to get an IP address using DHCP:");
if (!Ethernet.begin(mac)) {

View File

@ -9,7 +9,7 @@
created 4 Sep 2010
by Michael Margolis
modified 17 Sep 2010
modified 9 Apr 2012
by Tom Igoe
This code is in the public domain.
@ -38,7 +38,12 @@ EthernetUDP Udp;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start Ethernet and UDP
if (Ethernet.begin(mac) == 0) {

View File

@ -8,6 +8,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
modified 9 Apr 2012
by David A. Mellis
*/
@ -26,8 +27,12 @@ IPAddress server(173,194,33,104); // Google
EthernetClient client;
void setup() {
// start the serial library:
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -10,7 +10,7 @@
created 18 Dec 2009
by David A. Mellis
modified 20 Mar 2012
modified 9 Apr 2012
by Tom Igoe
*/
@ -30,7 +30,13 @@ IPAddress ip(192,168,1, 177);
EthernetServer server(80);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();

View File

@ -327,7 +327,11 @@ private:
inline static void initSS() { DDRB |= _BV(4); };
inline static void setSS() { PORTB &= ~_BV(4); };
inline static void resetSS() { PORTB |= _BV(4); };
#elif defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
#elif defined(__AVR_ATmega32U4__)
inline static void initSS() { DDRB |= _BV(6); };
inline static void setSS() { PORTB &= ~_BV(6); };
inline static void resetSS() { PORTB |= _BV(6); };
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
inline static void initSS() { DDRB |= _BV(0); };
inline static void setSS() { PORTB &= ~_BV(0); };
inline static void resetSS() { PORTB |= _BV(0); };

View File

@ -32,7 +32,8 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll
*/
// include the library code:

View File

@ -32,7 +32,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystalBlink
*/

View File

@ -33,7 +33,8 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystalCursor
*/
// include the library code:

View File

@ -33,7 +33,8 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystalDisplay
*/
// include the library code:

View File

@ -33,7 +33,8 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystalScroll
*/
// include the library code:

View File

@ -32,7 +32,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystalSerial
*/
// include the library code:

View File

@ -32,7 +32,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection
*/
@ -49,7 +49,6 @@ void setup() {
lcd.begin(16, 2);
// turn on the cursor:
lcd.cursor();
Serial.begin(9600);
}
void loop() {

View File

@ -32,7 +32,8 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor
*/
// include the library code:

View File

@ -16,7 +16,7 @@
created 28 Mar 2011
by Limor Fried
modified 16 Mar 2011
modified 9 Apr 2012
by Tom Igoe
*/
// include the SD library:
@ -35,7 +35,13 @@ const int chipSelect = 4;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("\nInitializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin

View File

@ -13,7 +13,7 @@
** CS - pin 4
created 24 Nov 2010
updated 2 Dec 2010
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
@ -30,7 +30,13 @@ const int chipSelect = 4;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:

View File

@ -12,6 +12,9 @@
** CS - pin 4
created 22 December 2010
by Limor Fried
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
@ -27,7 +30,13 @@ const int chipSelect = 4;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:

View File

@ -11,7 +11,7 @@
created Nov 2010
by David A. Mellis
updated 2 Dec 2010
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
@ -23,7 +23,13 @@ File myFile;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin

View File

@ -11,7 +11,7 @@
created Nov 2010
by David A. Mellis
updated 2 Dec 2010
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
@ -24,7 +24,13 @@ File myFile;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin

View File

@ -11,7 +11,7 @@
created Nov 2010
by David A. Mellis
updated 2 Dec 2010
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
@ -23,7 +23,13 @@ File root;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin

View File

@ -9,6 +9,7 @@
* TX is digital pin 3 (connect to RX of other device)
created back in the mists of time
modified 9 Apr 2012
by Tom Igoe
based on Mikal Hart's example
@ -21,7 +22,13 @@ SoftwareSerial mySerial(2, 3); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port

View File

@ -17,6 +17,7 @@
* Second serial device's TX attached to digital pin 4, RX to pin 5
created 18 Apr. 2011
modified 9 Apr 2012
by Tom Igoe
based on Mikal Hart's twoPortRXExample
@ -33,8 +34,12 @@ SoftwareSerial portTwo(4, 5);
void setup()
{
// Start the hardware serial port
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// Start each software serial port
portOne.begin(9600);

View File

@ -26,11 +26,10 @@ const int stepsPerRevolution = 200; // change this to fit the number of steps p
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);
int stepCount = 0; // number of steps the motor has taken
int stepCount = 0; // number of steps the motor has taken
void setup() {
// initialize the serial port:
Serial.begin(9600);
// nothing to do inside the setup
}
void loop() {