1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-15 12:29:26 +01:00

review of typos a and small errors in some examples

This commit is contained in:
Fede85 2012-10-18 19:03:25 +02:00
parent b89ef099a9
commit a21c4e153f
17 changed files with 56 additions and 85 deletions

View File

@ -11,6 +11,7 @@
This example code is in the public domain. This example code is in the public domain.
*/ */
String stringOne, stringTwo; String stringOne, stringTwo;
void setup() { void setup() {

View File

@ -11,6 +11,7 @@
This example code is in the public domain. This example code is in the public domain.
*/ */
String txtMsg = ""; // a string for incoming text String txtMsg = ""; // a string for incoming text
int lastStringLength = txtMsg.length(); // previous length of the String int lastStringLength = txtMsg.length(); // previous length of the String

View File

@ -49,9 +49,11 @@ EthernetClient client;
//IPAddress server(216,52,233,121); // numeric IP for api.cosm.com //IPAddress server(216,52,233,121); // numeric IP for api.cosm.com
char server[] = "api.cosm.com"; // name address for cosm API char server[] = "api.cosm.com"; // name address for cosm API
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds 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 boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000; //delay between updates to cosm.com const unsigned long postingInterval = 10L*1000L; // delay between updates to cosm.com
// the "L" is needed to use long type numbers
void setup() { void setup() {
// start serial port: // start serial port:

View File

@ -51,10 +51,10 @@ EthernetClient client;
//IPAddress server(216,52,233,121); // numeric IP for api.cosm.com //IPAddress server(216,52,233,121); // numeric IP for api.cosm.com
char server[] = "api.cosm.com"; // name address for Cosm API char server[] = "api.cosm.com"; // name address for Cosm API
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds 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 boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000; //delay between updates to Cosm.com const unsigned long postingInterval = 10L*1000L; // delay between updates to Cosm.com
// the "L" is needed to use long type numbers
void setup() { void setup() {
// start serial port: // start serial port:
Serial.begin(9600); Serial.begin(9600);

View File

@ -39,9 +39,10 @@ EthernetClient client;
char server[] = "www.arduino.cc"; char server[] = "www.arduino.cc";
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds 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 boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 60*1000; // delay between updates, in milliseconds const unsigned long postingInterval = 60L*1000L; // delay between updates, in milliseconds
// the "L" is needed to use long type numbers
void setup() { void setup() {
// start serial port: // start serial port:

View File

@ -46,17 +46,18 @@ EthernetClient client;
// if you don't want to use DNS (and reduce your sketch size) // if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server: // use the numeric IP instead of the name for the server:
//IPAddress server(216,52,233,121); // numeric IP for api.cosm.com // IPAddress server(216,52,233,121); // numeric IP for api.cosm.com
char server[] = "api.cosm.com"; // name address for cosm API char server[] = "api.cosm.com"; // name address for cosm API
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds 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 boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000; //delay between updates to cosm.com const unsigned long postingInterval = 10L*1000L; // delay between updates to cosm.com
// the "L" is needed to use long type numbers
void setup() { void setup() {
// start serial port: // start serial port:
Serial.begin(9600); Serial.begin(9600);
// start the Ethernet connection: // start the Ethernet connection:
if (Ethernet.begin(mac) == 0) { if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP"); Serial.println("Failed to configure Ethernet using DHCP");
// DHCP failed, so use a fixed IP address: // DHCP failed, so use a fixed IP address:

View File

@ -36,7 +36,7 @@
// assign a MAC address for the ethernet controller. // assign a MAC address for the ethernet controller.
// fill in your address here: // fill in your address here:
byte mac[] = { byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// fill in an available IP address on your network here, // fill in an available IP address on your network here,
@ -48,12 +48,13 @@ EthernetClient client;
// if you don't want to use DNS (and reduce your sketch size) // if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server: // use the numeric IP instead of the name for the server:
//IPAddress server(216,52,233,121); // numeric IP for api.cosm.com // IPAddress server(216,52,233,121); // numeric IP for api.cosm.com
char server[] = "api.cosm.com"; // name address for Cosm API char server[] = "api.cosm.com"; // name address for Cosm API
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds 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 boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000; //delay between updates to Cosm.com const unsigned long postingInterval = 10L*1000L; // delay between updates to Cosm.com
// the "L" is needed to use long type numbers
void setup() { void setup() {
// start serial port: // start serial port:

View File

@ -28,7 +28,7 @@ byte mac[] = {
EthernetClient client; EthernetClient client;
void setup() { void setup() {
// Open serial communications and wait for port to open: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
// this check is only needed on the Leonardo: // this check is only needed on the Leonardo:
while (!Serial) { while (!Serial) {

View File

@ -1,5 +1,5 @@
/* /*
DHCP Chat Server DHCP Chat Server
A simple server that distributes any incoming messages to all A simple server that distributes any incoming messages to all
connected clients. To use telnet to your device's IP address and type. connected clients. To use telnet to your device's IP address and type.
@ -26,9 +26,9 @@
// gateway and subnet are optional: // gateway and subnet are optional:
byte mac[] = { byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
IPAddress ip(192,168,1, 177); IPAddress ip(192,168,1,177);
IPAddress gateway(192,168,1, 1); IPAddress gateway(192,168,1,1);
IPAddress subnet(255, 255, 0, 0); IPAddress subnet(255,255,0,0);
// telnet defaults to port 23 // telnet defaults to port 23
EthernetServer server(23); EthernetServer server(23);

View File

@ -19,7 +19,7 @@
// Enter a MAC address for your controller below. // Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield // Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "www.google.com"; char serverName[] = "www.google.com";
// Initialize the Ethernet client library // Initialize the Ethernet client library
@ -28,7 +28,7 @@ char serverName[] = "www.google.com";
EthernetClient client; EthernetClient client;
void setup() { void setup() {
// Open serial communications and wait for port to open: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while (!Serial) { while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only ; // wait for serial port to connect. Needed for Leonardo only
@ -46,7 +46,6 @@ void setup() {
Serial.println("connecting..."); Serial.println("connecting...");
// if you get a connection, report back via serial: // if you get a connection, report back via serial:
if (client.connect(serverName, 80)) { if (client.connect(serverName, 80)) {
Serial.println("connected"); Serial.println("connected");
// Make a HTTP request: // Make a HTTP request:
@ -54,7 +53,7 @@ void setup() {
client.println(); client.println();
} }
else { else {
// kf you didn't get a connection to the server: // if you didn't get a connection to the server:
Serial.println("connection failed"); Serial.println("connection failed");
} }
} }

View File

@ -39,7 +39,7 @@ EthernetClient client;
void setup() { void setup() {
// start the Ethernet connection: // start the Ethernet connection:
Ethernet.begin(mac, ip); Ethernet.begin(mac, ip);
// Open serial communications and wait for port to open: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while (!Serial) { while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only ; // wait for serial port to connect. Needed for Leonardo only

View File

@ -1,5 +1,6 @@
/* /*
UDPSendReceive.pde: UDPSendReceive
This sketch receives UDP message strings, prints them to the serial port This sketch receives UDP message strings, prints them to the serial port
and sends an "acknowledge" string back to the sender and sends an "acknowledge" string back to the sender
@ -10,24 +11,25 @@
by Michael Margolis by Michael Margolis
This code is in the public domain. This code is in the public domain.
*/ */
#include <SPI.h> // needed for Arduino versions later than 0018 #include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h> #include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008 #include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
// Enter a MAC address and IP address for your controller below. // Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network: // The IP address will be dependent on your local network:
byte mac[] = { byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177); IPAddress ip(192, 168,1,177);
unsigned int localPort = 8888; // local port to listen on unsigned int localPort = 8888; // local port to listen on
// buffers for receiving and sending data // buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet, char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged"; // a string to send back char ReplyBuffer[] = "acknowledged"; // a string to send back
// An EthernetUDP instance to let us send and receive packets over UDP // An EthernetUDP instance to let us send and receive packets over UDP

View File

@ -1,6 +1,5 @@
/* /*
Udp NTP Client
Udp NTP Client
Get the time from a Network Time Protocol (NTP) time server Get the time from a Network Time Protocol (NTP) time server
Demonstrates use of UDP sendPacket and ReceivePacket Demonstrates use of UDP sendPacket and ReceivePacket
@ -38,7 +37,7 @@ EthernetUDP Udp;
void setup() void setup()
{ {
// Open serial communications and wait for port to open: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while (!Serial) { while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only ; // wait for serial port to connect. Needed for Leonardo only
@ -59,7 +58,7 @@ void loop()
{ {
sendNTPpacket(timeServer); // send an NTP packet to a time server sendNTPpacket(timeServer); // send an NTP packet to a time server
// wait to see if a reply is available // wait to see if a reply is available
delay(1000); delay(1000);
if ( Udp.parsePacket() ) { if ( Udp.parsePacket() ) {
// We've received a packet, read the data from it // We've received a packet, read the data from it

View File

@ -52,7 +52,7 @@ void setup() {
client.println(); client.println();
} }
else { else {
// kf you didn't get a connection to the server: // if you didn't get a connection to the server:
Serial.println("connection failed"); Serial.println("connection failed");
} }
} }

View File

@ -39,9 +39,10 @@ EthernetClient client;
char server[] = "www.arduino.cc"; char server[] = "www.arduino.cc";
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds 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 boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 60*1000; // delay between updates, in milliseconds const unsigned long postingInterval = 60L*1000L; // delay between updates, in milliseconds
// the "L" is needed to use long type numbers
void setup() { void setup() {
// start serial port: // start serial port:

View File

@ -22,7 +22,7 @@
// The IP address will be dependent on your local network: // The IP address will be dependent on your local network:
byte mac[] = { byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177); IPAddress ip(192,168,1,177);
// Initialize the Ethernet server library // Initialize the Ethernet server library
// with the IP address and port you want to use // with the IP address and port you want to use
@ -30,7 +30,7 @@ IPAddress ip(192,168,1, 177);
EthernetServer server(80); EthernetServer server(80);
void setup() { void setup() {
// Open serial communications and wait for port to open: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while (!Serial) { while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only ; // wait for serial port to connect. Needed for Leonardo only
@ -67,7 +67,7 @@ void loop() {
client.println(); client.println();
client.println("<!DOCTYPE HTML>"); client.println("<!DOCTYPE HTML>");
client.println("<html>"); client.println("<html>");
// add a meta refresh tag, so the browser pulls again every 5 seconds: // add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">"); client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin // output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) { for (int analogChannel = 0; analogChannel < 6; analogChannel++) {

View File

@ -1,37 +0,0 @@
#include <SPI.h>
// Flash memory is connected on SPI pin SS3
#define FLASH PIN_SPI_SS3
void setup() {
Serial.begin(9600);
// Start SPI with FLASH device
SPI.begin(FLASH);
// Half clock speed: we are too fast with 1
SPI.setClockDivider(FLASH, 2);
}
void loop() {
// Send "identify" command (9f) and receive response
// on the same SPI transaction. Parameter SPI_CONTINUE
// keeps the SS pin active.
Serial.println("Sending 'Identify' cmd to flash => 9F");
SPI.transfer(FLASH, 0x9f, SPI_CONTINUE);
char a1 = SPI.transfer(FLASH, 0x00, SPI_CONTINUE);
char a2 = SPI.transfer(FLASH, 0x00, SPI_CONTINUE);
char a3 = SPI.transfer(FLASH, 0x00, SPI_CONTINUE);
char a4 = SPI.transfer(FLASH, 0x00, SPI_CONTINUE);
char a5 = SPI.transfer(FLASH, 0x00);
// Print response over serial port
Serial.print("Received signature: ");
Serial.print(a1, HEX);
Serial.print(a2, HEX);
Serial.print(a3, HEX);
Serial.print(a4, HEX);
Serial.println(a5, HEX);
delay(1000);
}