1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-01 03:47:23 +03:00

Merge branch 'new-extension' of github.com:arduino/Arduino into diskloader_reboot

Conflicts:
	hardware/arduino/variants/mega/pins_arduino.h
	libraries/Ethernet/examples/PachubeClient/PachubeClient.ino
	libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino
This commit is contained in:
Zach Eveland
2011-10-27 11:41:02 -04:00
14 changed files with 212 additions and 226 deletions

View File

@ -11,7 +11,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010
updated 4 Sep 2010
updated 26 Oct 2011
by Tom Igoe
http://www.tigoe.net/pcomp/code/category/arduinowiring/873
@ -23,34 +23,32 @@
#include <Ethernet.h>
// assign a MAC address for the ethernet controller.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
// fill in your address here:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// assign an IP address for the controller:
byte ip[] = {
192,168,1,20 };
byte gateway[] = {
192,168,1,1};
byte subnet[] = {
255, 255, 255, 0 };
// The address of the server you want to connect to (pachube.com):
byte server[] = {
173,203,98,29 };
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(10,0,1,20);
// initialize the library instance:
Client client(server, 80);
EthernetClient client;
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 int postingInterval = 10000; //delay between updates to Pachube.com
void setup() {
// start the ethernet connection and serial port:
Ethernet.begin(mac, ip);
// start serial port:
Serial.begin(9600);
// give the ethernet module time to boot up:
delay(1000);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Configure manually:
Ethernet.begin(mac, ip);
}
}
void loop() {
@ -86,7 +84,7 @@ void loop() {
// this method makes a HTTP connection to the server:
void sendData(int thisData) {
// if there's a successful connection:
if (client.connect()) {
if (client.connect("www.pachube.com", 80)) {
Serial.println("connecting...");
// send the HTTP PUT request.
// fill in your feed address here:

View File

@ -14,7 +14,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010
updated 4 Sep 2010
updated 26 Oct 2011
by Tom Igoe
This code is in the public domain.
@ -28,31 +28,28 @@
// fill in your address here:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// assign an IP address for the controller:
byte ip[] = {
192,168,1,20 };
byte gateway[] = {
192,168,1,1};
byte subnet[] = {
255, 255, 255, 0 };
// The address of the server you want to connect to (pachube.com):
byte server[] = {
173,203,98,29 };
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(10,0,1,20);
// initialize the library instance:
Client client(server, 80);
EthernetClient client;
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 int postingInterval = 10000; //delay between updates to Pachube.com
void setup() {
// start the ethernet connection and serial port:
Ethernet.begin(mac, ip);
// start serial port:
Serial.begin(9600);
// give the ethernet module time to boot up:
delay(1000);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Configure manually:
Ethernet.begin(mac, ip);
}
}
void loop() {
@ -96,7 +93,7 @@ void loop() {
// this method makes a HTTP connection to the server:
void sendData(String thisData) {
// if there's a successful connection:
if (client.connect()) {
if (client.connect("www.pachube.com", 80)) {
Serial.println("connecting...");
// send the HTTP PUT request.
// fill in your feed address here:

View File

@ -0,0 +1,43 @@
/*
Keyboard Button test
Sends a text string when a button is pressed.
The circuit:
* pushbutton attached from pin 4 to +5V
* 10-kilohm resistor attached from pin 4 to ground
created 24 Oct 2011
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/KeyboardButton
*/
const int buttonPin = 4; // input pin for pushbutton
int previousButtonState = HIGH; // for checking the state of a pushButton
int counter = 0; // button push counter
void setup() {
// make the pushButton pin an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the pushbutton:
int buttonState = digitalRead(buttonPin);
// if the button state has changed,
if ((buttonState != previousButtonState)
// and it's currently pressed:
&& (buttonState == HIGH)) {
// increment the button counter
counter++;
// type out a message
Keyboard.print("You pressed the button: ");
Keyboard.print(counter);
Keyboard.println(" times.");
}
// save the current button state for comparison next time:
previousButtonState = buttonState;
}

View File

@ -0,0 +1,33 @@
/*
Keyboard test
Reads a byte from the serial port, sends a keystroke back.
The sent keystroke is one higher than what's received, e.g.
if you send a, you get b, send A you get B, and so forth.
The circuit:
* none
created 21 Oct 2011
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/KeyboardSerial
*/
void setup() {
// open the serial port:
Serial.begin(9600);
}
void loop() {
// check for incoming serial data:
if (Serial.available() > 0) {
// read incoming serial data:
char inChar = Serial.read();
// Type the next ASCII value from what you received:
Keyboard.write(inChar+1);
}
}