Commit 8669e7bc authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+15 −0
Changes for README.md: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
## Example files for the title:  
	  
# Building Wireless Sensor Networks, by Robert Faludi
	  
[![Building Wireless Sensor Networks, by Robert Faludi](http://akamaicovers.oreilly.com/images/9780596807733/cat.gif)](https://www.safaribooksonline.com/library/view/title/780596807757//)
	  
The following applies to example files from material published by O’Reilly Media, Inc. Content from other publishers may include different rules of usage. Please refer to any additional usage rights explained in the actual example files or refer to the publisher’s website.
	  
O'Reilly books are here to help you get your job done. In general, you may use the code in O'Reilly books in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from our books does not require permission. Answering a question by citing our books and quoting example code does not require permission. On the other hand, selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Incorporating a significant amount of example code from our books into your product's documentation does require permission.
	  
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
	  
If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at <permissions@oreilly.com>.
	  
Please note that the examples are not production code and have not been carefully testing. They are provided "as-is" and come with no warranty of any kind.

XIG_Light_Example.pde

0 → 100644
+50 −0
Changes for XIG_Light_Example.pde: 50 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * *********XBee Internet Gateway Light Example********
 * by Rob Faludi http://faludi.com
 * rewritten for St. Ann's http://saintannsny.org
 */

#define NAME "XIG Light Example"
#define VERSION "1.10"
#define LED_PIN 13

int outputLight = 12;
int lightState;

void setup() {
  pinMode(LED_PIN,OUTPUT);
  pinMode(outputLight,OUTPUT);
  blinkLED(LED_PIN,2,100);
  blinkLED(outputLight,2,100);
  Serial.begin(115200); // faster is better for XIG
  delay(2000);
}


void loop() {
  if (millis() % 1000 == 0) {  // wait a second before sending the next request
  // request the current light state, set with zig_light_form_example.php
  Serial.println("<YOUR-SERVER-HERE>/lightSetting.txt");
  }
  if (Serial.available() > 0) { // if there's a byte waiting
    lightState = Serial.read(); // read the ASCII numeral byte
    // turn on the light if the response is 1, or off if the response is zero
    if (lightState == '0' || lightState=='1') {
      lightState=lightState-48; // transform ASCII into an integer
    digitalWrite(outputLight, lightState);
    }
  }
}


////////////////// UTILITIES //////////////////
// this function blinks the an LED light as many times as requested, at the requested blinking rate
void blinkLED(byte targetPin, int numBlinks, int blinkRate) {
  for (int i=0; i<numBlinks; i++) {
    digitalWrite(targetPin, HIGH);   // sets the LED on
    delay(blinkRate);                     // waits for blinkRate milliseconds
    digitalWrite(targetPin, LOW);    // sets the LED off
    delay(blinkRate);
  }
}

XIG_Upload_Example.pde

0 → 100644
+43 −0
Changes for XIG_Upload_Example.pde: 43 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * *********XBee Internet Gateway Upload Example********
 * by Rob Faludi http://faludi.com
 */

#define NAME "XIG Upload Example"
#define VERSION "1.00"
#define LED_PIN 13

int inputPin = 0;

void setup() {
  pinMode(LED_PIN,OUTPUT);
  blinkLED(LED_PIN,2,100);
  Serial.begin(115200); // faster is better for XIG
  delay(2000);
}


void loop() {
  // read the analog pin
  int value = analogRead(inputPin);
  // upload the current value to the server, it will be stored in a dataFile.txt
  Serial.print("<YOUR-SERVER-HERE>/xig_upload_example.php?value=");
  Serial.println(value, DEC);
  // wait a second between uploads
  delay(1000);
  blinkLED(LED_PIN,1,100);
}


////////////////// UTILITIES //////////////////
// this function blinks the an LED light as many times as requested, at the requested blinking rate
void blinkLED(byte targetPin, int numBlinks, int blinkRate) {
  for (int i=0; i<numBlinks; i++) {
    digitalWrite(targetPin, HIGH);   // sets the LED on
    delay(blinkRate);                     // waits for blinkRate milliseconds
    digitalWrite(targetPin, LOW);    // sets the LED off
    delay(blinkRate);
  }
}

+167 B

File added.

No diff preview for this file type.

__MACOSX/._iofile.txt

0 → 100644
+167 B

File added.

No diff preview for this file type.

Loading