1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Run new astyle formatter against all the examples

This commit is contained in:
Federico Fissore
2013-10-21 09:58:40 +02:00
parent 3c6ee46828
commit b4c68b3dff
259 changed files with 5160 additions and 5217 deletions

View File

@ -1,12 +1,12 @@
/*
Arduino Yun Bridge example
This example for the Arduino Yun shows how to use the
Bridge library to access the digital and analog pins
on the board through REST calls. It demonstrates how
you can create your own API when using REST style
This example for the Arduino Yun shows how to use the
Bridge library to access the digital and analog pins
on the board through REST calls. It demonstrates how
you can create your own API when using REST style
calls through the browser.
Possible commands created in this shetch:
* "/arduino/digital/13" -> digitalRead(13)
@ -15,9 +15,9 @@
* "/arduino/analog/2" -> analogRead(2)
* "/arduino/mode/13/input" -> pinMode(13, INPUT)
* "/arduino/mode/13/output" -> pinMode(13, OUTPUT)
This example code is part of the public domain
http://arduino.cc/en/Tutorial/Bridge
*/
@ -32,7 +32,7 @@ YunServer server;
void setup() {
// Bridge startup
pinMode(13,OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);
@ -90,7 +90,7 @@ void digitalCommand(YunClient client) {
if (client.read() == '/') {
value = client.parseInt();
digitalWrite(pin, value);
}
}
else {
value = digitalRead(pin);
}

View File

@ -1,95 +1,95 @@
/*
ASCII table
Prints out byte values in all possible formats:
Prints out byte values in all possible formats:
* as raw binary values
* as ASCII-encoded decimal, hex, octal, and binary values
For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII
The circuit: No external hardware needed.
created 2006
by Nicholas Zambetti
by Nicholas Zambetti
http://www.zambetti.com
modified 9 Apr 2012
by Tom Igoe
modified 22 May 2013
by Cristian Maglie
This example code is in the public domain.
http://arduino.cc/en/Tutorial/ConsoleAsciiTable
*/
#include <Console.h>
void setup() {
//Initialize Console and wait for port to open:
void setup() {
//Initialize Console and wait for port to open:
Bridge.begin();
Console.begin();
Console.begin();
// Uncomment the following line to enable buffering:
// - better transmission speed and efficiency
// - needs to call Console.flush() to ensure that all
// - needs to call Console.flush() to ensure that all
// transmitted data is sent
//Console.buffer(64);
while (!Console) {
; // wait for Console port to connect.
}
// prints title with ending line break
Console.println("ASCII Table ~ Character Map");
}
// prints title with ending line break
Console.println("ASCII Table ~ Character Map");
}
// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33;
int thisByte = 33;
// you can also write ASCII characters in single quotes.
// for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!';
//int thisByte = '!';
void loop() {
// prints value unaltered, i.e. the raw binary version of the
// byte. The Console monitor interprets all bytes as
// ASCII, so 33, the first number, will show up as '!'
Console.write(thisByte);
void loop() {
// prints value unaltered, i.e. the raw binary version of the
// byte. The Console monitor interprets all bytes as
// ASCII, so 33, the first number, will show up as '!'
Console.write(thisByte);
Console.print(", dec: ");
Console.print(", dec: ");
// prints value as string as an ASCII-encoded decimal (base 10).
// Decimal is the default format for Console.print() and Console.println(),
// so no modifier is needed:
Console.print(thisByte);
Console.print(thisByte);
// But you can declare the modifier for decimal if you want to.
//this also works if you uncomment it:
// Console.print(thisByte, DEC);
// Console.print(thisByte, DEC);
Console.print(", hex: ");
Console.print(", hex: ");
// prints value as string in hexadecimal (base 16):
Console.print(thisByte, HEX);
Console.print(thisByte, HEX);
Console.print(", oct: ");
Console.print(", oct: ");
// prints value as string in octal (base 8);
Console.print(thisByte, OCT);
Console.print(thisByte, OCT);
Console.print(", bin: ");
// prints value as string in binary (base 2)
Console.print(", bin: ");
// prints value as string in binary (base 2)
// also prints ending line break:
Console.println(thisByte, BIN);
Console.println(thisByte, BIN);
// if printed last visible character '~' or 126, stop:
if(thisByte == 126) { // you could also use if (thisByte == '~') {
// if printed last visible character '~' or 126, stop:
if (thisByte == 126) { // you could also use if (thisByte == '~') {
// ensure the latest bit of data is sent
Console.flush();
// This loop loops forever and does nothing
while(true) {
continue;
}
}
while (true) {
continue;
}
}
// go on to the next character
thisByte++;
}
thisByte++;
}

View File

@ -1,30 +1,30 @@
/*
Console Pixel
An example of using the Arduino board to receive data from the
An example of using the Arduino board to receive data from the
Console on the Arduino Yun. In this case, the Arduino boards turns on an LED when
it receives the character 'H', and turns off the LED when it
receives the character 'L'.
To see the Console, pick your Yún's name and IP address in the Port menu
then open the Port Monitor. You can also see it by opening a terminal window
and typing
and typing
ssh root@ yourYunsName.local 'telnet localhost 6571'
then pressing enter. When prompted for the password, enter it.
The circuit:
* LED connected from digital pin 13 to ground
created 2006
by David A. Mellis
modified 25 Jun 2013
by Tom Igoe
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/ConsolePixel
*/
#include <Console.h>
@ -37,7 +37,7 @@ void setup() {
Console.begin(); // Initialize Console
// Wait for the Console port to connect
while(!Console);
while (!Console);
Console.println("type H or L to turn pin 13 on or off");
@ -54,7 +54,7 @@ void loop() {
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);

View File

@ -3,22 +3,22 @@
Read data coming from bridge using the Console.read() function
and store it in a string.
To see the Console, pick your Yún's name and IP address in the Port menu
then open the Port Monitor. You can also see it by opening a terminal window
and typing:
and typing:
ssh root@ yourYunsName.local 'telnet localhost 6571'
then pressing enter. When prompted for the password, enter it.
created 13 Jun 2013
by Angelo Scialabba
by Angelo Scialabba
modified 16 June 2013
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/ConsoleRead
*/
#include <Console.h>
@ -28,13 +28,13 @@ String name;
void setup() {
// Initialize Console and wait for port to open:
Bridge.begin();
Console.begin();
Console.begin();
// Wait for Console port to connect
while (!Console);
while (!Console);
Console.println("Hi, what's your name?");
}
}
void loop() {
if (Console.available() > 0) {
@ -49,7 +49,7 @@ void loop() {
// Ask again for name and clear the old name
Console.println("Hi, what's your name?");
name = ""; // clear the name string
}
}
else { // if the buffer is empty Cosole.read() returns -1
name += c; // append the read char from Console to the name string
}

View File

@ -1,21 +1,21 @@
/*
SD card datalogger
This example shows how to log data from three analog sensors
This example shows how to log data from three analog sensors
to an SD card mounted on the Arduino Yún using the Bridge library.
The circuit:
* analog sensors on analog pins 0, 1 and 2
* SD card attached to SD card slot of the Arduino Yún
Prepare your SD card creating an empty folder in the SD root
named "arduino". This will ensure that the Yún will create a link
Prepare your SD card creating an empty folder in the SD root
named "arduino". This will ensure that the Yún will create a link
to the SD to the "/mnt/sd" path.
You can remove the SD card while the Linux and the
You can remove the SD card while the Linux and the
sketch are running but be careful not to remove it while
the system is writing to it.
created 24 Nov 2010
modified 9 Apr 2012
by Tom Igoe
@ -23,11 +23,11 @@
by Federico Vanzati
modified 21 Jun 2013
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/YunDatalogger
*/
#include <FileIO.h>
@ -38,7 +38,7 @@ void setup() {
Serial.begin(9600);
FileSystem.begin();
while(!Serial); // wait for Serial port to connect.
while (!Serial); // wait for Serial port to connect.
Serial.println("Filesystem datalogger\n");
}
@ -69,12 +69,12 @@ void loop () {
dataFile.close();
// print to the serial port too:
Serial.println(dataString);
}
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening datalog.txt");
}
}
delay(15000);
}
@ -83,19 +83,19 @@ void loop () {
String getTimeStamp() {
String result;
Process time;
// date is a command line utility to get the date and the time
// in different formats depending on the additional parameter
// date is a command line utility to get the date and the time
// in different formats depending on the additional parameter
time.begin("date");
time.addParameter("+%D-%T"); // parameters: D for the complete date mm/dd/yy
// T for the time hh:mm:ss
// T for the time hh:mm:ss
time.run(); // run the command
// read the output of the command
while(time.available()>0) {
while (time.available() > 0) {
char c = time.read();
if(c != '\n')
if (c != '\n')
result += c;
}
return result;
}

View File

@ -1,18 +1,18 @@
/*
Write to file using FileIO classes.
This sketch demonstrate how to write file into the Yún filesystem.
A shell script file is created in /tmp, and it is executed afterwards.
created 7 June 2010
by Cristian Maglie
by Cristian Maglie
This example code is in the public domain.
http://arduino.cc/en/Tutorial/FileWriteScript
*/
#include <FileIO.h>
void setup() {
@ -20,16 +20,16 @@ void setup() {
Bridge.begin();
// Initialize the Serial
Serial.begin(9600);
while(!Serial); // wait for Serial port to connect.
while (!Serial); // wait for Serial port to connect.
Serial.println("File Write Script example\n\n");
// Setup File IO
FileSystem.begin();
// Upload script used to gain network statistics
// Upload script used to gain network statistics
uploadScript();
}
}
void loop() {
// Run stats script every 5 secs.
@ -41,10 +41,10 @@ void loop() {
// to check the network traffic of the WiFi interface
void uploadScript() {
// Write our shell script in /tmp
// Using /tmp stores the script in RAM this way we can preserve
// Using /tmp stores the script in RAM this way we can preserve
// the limited amount of FLASH erase/write cycles
File script = FileSystem.open("/tmp/wlan-stats.sh", FILE_WRITE);
// Shell script header
// Shell script header
script.print("#!/bin/sh\n");
// shell commands:
// ifconfig: is a command line utility for controlling the network interfaces.
@ -53,7 +53,7 @@ void uploadScript() {
// and extract the line that contains it
script.print("ifconfig wlan0 | grep 'RX bytes'\n");
script.close(); // close the file
// Make the script executable
Process chmod;
chmod.begin("chmod"); // chmod: change mode
@ -69,9 +69,9 @@ void runScript() {
Process myscript;
myscript.begin("/tmp/wlan-stats.sh");
myscript.run();
String output = "";
// read the output of the script
while (myscript.available()) {
output += (char)myscript.read();

View File

@ -1,9 +1,9 @@
/*
Yun HTTP Client
This example for the Arduino Yún shows how create a basic
HTTP client that connects to the internet and downloads
content. In this case, you'll connect to the Arduino
This example for the Arduino Yún shows how create a basic
HTTP client that connects to the internet and downloads
content. In this case, you'll connect to the Arduino
website and download a version of the logo as ASCII text.
created by Tom igoe
@ -21,32 +21,32 @@
void setup() {
// Bridge takes about two seconds to start up
// it can be helpful to use the on-board LED
// as an indicator for when it has initialized
// as an indicator for when it has initialized
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);
Serial.begin(9600);
while(!Serial); // wait for a serial connection
while (!Serial); // wait for a serial connection
}
void loop() {
// Initialize the client library
HttpClient client;
// Make a HTTP request:
client.get("http://arduino.cc/asciilogo.txt");
// if there are incoming bytes available
// from the server, read them and print them:
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
Serial.print(c);
}
Serial.flush();
delay(5000);
}

View File

@ -1,14 +1,14 @@
/*
Running process using Process class.
Running process using Process class.
This sketch demonstrate how to run linux processes
using an Arduino Yún.
using an Arduino Yún.
created 5 Jun 2013
by Cristian Maglie
This example code is in the public domain.
http://arduino.cc/en/Tutorial/Process
*/
@ -18,10 +18,10 @@
void setup() {
// Initialize Bridge
Bridge.begin();
// Initialize Serial
Serial.begin(9600);
// Wait until a Serial Monitor is connected.
while (!Serial);
@ -44,7 +44,7 @@ void runCurl() {
// Print arduino logo over the Serial
// A process output can be read with the stream methods
while (p.available()>0) {
while (p.available() > 0) {
char c = p.read();
Serial.print(c);
}
@ -62,7 +62,7 @@ void runCpuInfo() {
// Print command output on the Serial.
// A process output can be read with the stream methods
while (p.available()>0) {
while (p.available() > 0) {
char c = p.read();
Serial.print(c);
}

View File

@ -1,24 +1,24 @@
/*
Running shell commands using Process class.
Running shell commands using Process class.
This sketch demonstrate how to run linux shell commands
using an Arduino Yún. It runs the wifiCheck script on the linino side
of the Yun, then uses grep to get just the signal strength line.
Then it uses parseInt() to read the wifi signal strength as an integer,
and finally uses that number to fade an LED using analogWrite().
The circuit:
* Arduino Yun with LED connected to pin 9
created 12 Jun 2013
by Cristian Maglie
modified 25 June 2013
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/ShellCommands
*/
#include <Process.h>
@ -28,18 +28,18 @@ void setup() {
Serial.begin(9600); // Initialize the Serial
// Wait until a Serial Monitor is connected.
while(!Serial);
while (!Serial);
}
void loop() {
Process p;
// This command line runs the WifiStatus script, (/usr/bin/pretty-wifi-info.lua), then
// This command line runs the WifiStatus script, (/usr/bin/pretty-wifi-info.lua), then
// sends the result to the grep command to look for a line containing the word
// "Signal:" the result is passed to this sketch:
p.runShellCommand("/usr/bin/pretty-wifi-info.lua | grep Signal");
// do nothing until the process finishes, so you get the whole output:
while(p.running());
while (p.running());
// Read command output. runShellCommand() should have passed "Signal: xx&":
while (p.available()) {
@ -47,7 +47,7 @@ void loop() {
int signal = map(result, 0, 100, 0, 255); // map result from 0-100 range to 0-255
analogWrite(9, signal); // set the brightness of LED on pin 9
Serial.println(result); // print the number as well
}
}
delay(5000); // wait 5 seconds before you do it again
}

View File

@ -2,23 +2,23 @@
Input Output
Demonstrates how to create a sketch that sends and receives all standard
spacebrew data types, and a custom data type. Every time data is
spacebrew data types, and a custom data type. Every time data is
received it is output to the Serial monitor.
Make sure that your Yun is connected to the internet for this example
Make sure that your Yun is connected to the internet for this example
to function properly.
The circuit:
- No circuit required
created 2013
by Julio Terra
This example code is in the public domain.
More information about Spacebrew is available at:
More information about Spacebrew is available at:
http://spacebrew.cc/
*/
#include <Bridge.h>
@ -33,98 +33,100 @@ int interval = 2000;
int counter = 0;
void setup() {
void setup() {
// start the serial port
Serial.begin(57600);
// start the serial port
Serial.begin(57600);
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial) { ; }
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial) {
;
}
// start-up the bridge
Bridge.begin();
// start-up the bridge
Bridge.begin();
// configure the spacebrew object to print status messages to serial
sb.verbose(true);
// configure the spacebrew object to print status messages to serial
sb.verbose(true);
// configure the spacebrew publisher and subscriber
sb.addPublish("string test", "string");
sb.addPublish("range test", "range");
sb.addPublish("boolean test", "boolean");
sb.addPublish("custom test", "crazy");
sb.addSubscribe("string test", "string");
sb.addSubscribe("range test", "range");
sb.addSubscribe("boolean test", "boolean");
sb.addSubscribe("custom test", "crazy");
// configure the spacebrew publisher and subscriber
sb.addPublish("string test", "string");
sb.addPublish("range test", "range");
sb.addPublish("boolean test", "boolean");
sb.addPublish("custom test", "crazy");
sb.addSubscribe("string test", "string");
sb.addSubscribe("range test", "range");
sb.addSubscribe("boolean test", "boolean");
sb.addSubscribe("custom test", "crazy");
// register the string message handler method
sb.onRangeMessage(handleRange);
sb.onStringMessage(handleString);
sb.onBooleanMessage(handleBoolean);
sb.onCustomMessage(handleCustom);
// register the string message handler method
sb.onRangeMessage(handleRange);
sb.onStringMessage(handleString);
sb.onBooleanMessage(handleBoolean);
sb.onCustomMessage(handleCustom);
// connect to cloud spacebrew server at "sandbox.spacebrew.cc"
sb.connect("sandbox.spacebrew.cc");
// connect to cloud spacebrew server at "sandbox.spacebrew.cc"
sb.connect("sandbox.spacebrew.cc");
}
}
void loop() {
// monitor spacebrew connection for new data
sb.monitor();
void loop() {
// monitor spacebrew connection for new data
sb.monitor();
// connected to spacebrew then send a string every 2 seconds
if ( sb.connected() ) {
// connected to spacebrew then send a string every 2 seconds
if ( sb.connected() ) {
// check if it is time to send a new message
if ( (millis() - last) > interval ) {
String test_str_msg = "testing, testing, ";
test_str_msg += counter;
counter ++;
// check if it is time to send a new message
if ( (millis() - last) > interval ) {
String test_str_msg = "testing, testing, ";
test_str_msg += counter;
counter ++;
sb.send("string test", test_str_msg);
sb.send("range test", 500);
sb.send("boolean test", true);
sb.send("custom test", "youre loco");
sb.send("string test", test_str_msg);
sb.send("range test", 500);
sb.send("boolean test", true);
sb.send("custom test", "youre loco");
last = millis();
last = millis();
}
}
}
}
}
}
// define handler methods, all standard data type handlers take two appropriate arguments
void handleRange (String route, int value) {
Serial.print("Range msg ");
Serial.print(route);
Serial.print(", value ");
Serial.println(value);
Serial.print("Range msg ");
Serial.print(route);
Serial.print(", value ");
Serial.println(value);
}
void handleString (String route, String value) {
Serial.print("String msg ");
Serial.print(route);
Serial.print(", value ");
Serial.println(value);
Serial.print("String msg ");
Serial.print(route);
Serial.print(", value ");
Serial.println(value);
}
void handleBoolean (String route, boolean value) {
Serial.print("Boolen msg ");
Serial.print(route);
Serial.print(", value ");
Serial.println(value ? "true" : "false");
Serial.print("Boolen msg ");
Serial.print(route);
Serial.print(", value ");
Serial.println(value ? "true" : "false");
}
// custom data type handlers takes three String arguments
void handleCustom (String route, String value, String type) {
Serial.print("Custom msg ");
Serial.print(route);
Serial.print(" of type ");
Serial.print(type);
Serial.print(", value ");
Serial.println(value);
Serial.print("Custom msg ");
Serial.print(route);
Serial.print(" of type ");
Serial.print(type);
Serial.print(", value ");
Serial.println(value);
}

View File

@ -1,26 +1,26 @@
/*
Spacebrew Boolean
Demonstrates how to create a sketch that sends and receives a
boolean value to and from Spacebrew. Every time the buttton is
pressed (or other digital input component) a spacebrew message
is sent. The sketch also accepts analog range messages from
boolean value to and from Spacebrew. Every time the buttton is
pressed (or other digital input component) a spacebrew message
is sent. The sketch also accepts analog range messages from
other Spacebrew apps.
Make sure that your Yun is connected to the internet for this example
Make sure that your Yun is connected to the internet for this example
to function properly.
The circuit:
- Button connected to Yun, using the Arduino's internal pullup resistor.
created 2013
by Julio Terra
This example code is in the public domain.
More information about Spacebrew is available at:
More information about Spacebrew is available at:
http://spacebrew.cc/
*/
#include <Bridge.h>
@ -33,57 +33,59 @@ SpacebrewYun sb = SpacebrewYun("spacebrewYun Boolean", "Boolean sender and recei
int last_value = 0;
// create variables to manage interval between each time we send a string
void setup() {
void setup() {
// start the serial port
Serial.begin(57600);
// start the serial port
Serial.begin(57600);
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial) { ; }
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial) {
;
}
// start-up the bridge
Bridge.begin();
// start-up the bridge
Bridge.begin();
// configure the spacebrew object to print status messages to serial
sb.verbose(true);
// configure the spacebrew object to print status messages to serial
sb.verbose(true);
// configure the spacebrew publisher and subscriber
sb.addPublish("physical button", "boolean");
sb.addSubscribe("virtual button", "boolean");
// configure the spacebrew publisher and subscriber
sb.addPublish("physical button", "boolean");
sb.addSubscribe("virtual button", "boolean");
// register the string message handler method
sb.onBooleanMessage(handleBoolean);
// register the string message handler method
sb.onBooleanMessage(handleBoolean);
// connect to cloud spacebrew server at "sandbox.spacebrew.cc"
sb.connect("sandbox.spacebrew.cc");
// connect to cloud spacebrew server at "sandbox.spacebrew.cc"
sb.connect("sandbox.spacebrew.cc");
pinMode(3, INPUT);
digitalWrite(3, HIGH);
}
void loop() {
// monitor spacebrew connection for new data
sb.monitor();
// connected to spacebrew then send a new value whenever the pot value changes
if ( sb.connected() ) {
int cur_value = digitalRead(3);
if ( last_value != cur_value ) {
if (cur_value == HIGH) sb.send("physical button", false);
else sb.send("physical button", true);
last_value = cur_value;
}
}
}
// handler method that is called whenever a new string message is received
void handleBoolean (String route, boolean value) {
// print the message that was received
Serial.print("From ");
Serial.print(route);
Serial.print(", received msg: ");
Serial.println(value ? "true" : "false");
pinMode(3, INPUT);
digitalWrite(3, HIGH);
}
void loop() {
// monitor spacebrew connection for new data
sb.monitor();
// connected to spacebrew then send a new value whenever the pot value changes
if ( sb.connected() ) {
int cur_value = digitalRead(3);
if ( last_value != cur_value ) {
if (cur_value == HIGH) sb.send("physical button", false);
else sb.send("physical button", true);
last_value = cur_value;
}
}
}
// handler method that is called whenever a new string message is received
void handleBoolean (String route, boolean value) {
// print the message that was received
Serial.print("From ");
Serial.print(route);
Serial.print(", received msg: ");
Serial.println(value ? "true" : "false");
}

View File

@ -1,27 +1,27 @@
/*
Spacebrew Range
Demonstrates how to create a sketch that sends and receives analog
range value to and from Spacebrew. Every time the state of the
range value to and from Spacebrew. Every time the state of the
potentiometer (or other analog input component) change a spacebrew
message is sent. The sketch also accepts analog range messages from
message is sent. The sketch also accepts analog range messages from
other Spacebrew apps.
Make sure that your Yun is connected to the internet for this example
Make sure that your Yun is connected to the internet for this example
to function properly.
The circuit:
- Potentiometer connected to Yun. Middle pin connected to analog pin A0,
- Potentiometer connected to Yun. Middle pin connected to analog pin A0,
other pins connected to 5v and GND pins.
created 2013
by Julio Terra
This example code is in the public domain.
More information about Spacebrew is available at:
More information about Spacebrew is available at:
http://spacebrew.cc/
*/
#include <Bridge.h>
@ -34,53 +34,55 @@ SpacebrewYun sb = SpacebrewYun("spacebrewYun Range", "Range sender and receiver"
int last_value = 0;
// create variables to manage interval between each time we send a string
void setup() {
void setup() {
// start the serial port
Serial.begin(57600);
// start the serial port
Serial.begin(57600);
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial) { ; }
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial) {
;
}
// start-up the bridge
Bridge.begin();
// start-up the bridge
Bridge.begin();
// configure the spacebrew object to print status messages to serial
sb.verbose(true);
// configure the spacebrew object to print status messages to serial
sb.verbose(true);
// configure the spacebrew publisher and subscriber
sb.addPublish("physical pot", "range");
sb.addSubscribe("virtual pot", "range");
// configure the spacebrew publisher and subscriber
sb.addPublish("physical pot", "range");
sb.addSubscribe("virtual pot", "range");
// register the string message handler method
sb.onRangeMessage(handleRange);
// register the string message handler method
sb.onRangeMessage(handleRange);
// connect to cloud spacebrew server at "sandbox.spacebrew.cc"
sb.connect("sandbox.spacebrew.cc");
}
void loop() {
// monitor spacebrew connection for new data
sb.monitor();
// connected to spacebrew then send a new value whenever the pot value changes
if ( sb.connected() ) {
int cur_value = analogRead(A0);
if ( last_value != cur_value ) {
sb.send("physical pot", cur_value);
last_value = cur_value;
}
}
}
// handler method that is called whenever a new string message is received
void handleRange (String route, int value) {
// print the message that was received
Serial.print("From ");
Serial.print(route);
Serial.print(", received msg: ");
Serial.println(value);
// connect to cloud spacebrew server at "sandbox.spacebrew.cc"
sb.connect("sandbox.spacebrew.cc");
}
void loop() {
// monitor spacebrew connection for new data
sb.monitor();
// connected to spacebrew then send a new value whenever the pot value changes
if ( sb.connected() ) {
int cur_value = analogRead(A0);
if ( last_value != cur_value ) {
sb.send("physical pot", cur_value);
last_value = cur_value;
}
}
}
// handler method that is called whenever a new string message is received
void handleRange (String route, int value) {
// print the message that was received
Serial.print("From ");
Serial.print(route);
Serial.print(", received msg: ");
Serial.println(value);
}

View File

@ -1,24 +1,24 @@
/*
Spacebrew String
Demonstrates how to create a sketch that sends and receives strings
to and from Spacebrew. Every time string data is received it
to and from Spacebrew. Every time string data is received it
is output to the Serial monitor.
Make sure that your Yun is connected to the internet for this example
Make sure that your Yun is connected to the internet for this example
to function properly.
The circuit:
- No circuit required
created 2013
by Julio Terra
This example code is in the public domain.
More information about Spacebrew is available at:
More information about Spacebrew is available at:
http://spacebrew.cc/
*/
#include <Bridge.h>
@ -31,54 +31,56 @@ SpacebrewYun sb = SpacebrewYun("spacebrewYun Strings", "String sender and receiv
long last_time = 0;
int interval = 2000;
void setup() {
void setup() {
// start the serial port
Serial.begin(57600);
// start the serial port
Serial.begin(57600);
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial) { ; }
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial) {
;
}
// start-up the bridge
Bridge.begin();
// start-up the bridge
Bridge.begin();
// configure the spacebrew object to print status messages to serial
sb.verbose(true);
// configure the spacebrew object to print status messages to serial
sb.verbose(true);
// configure the spacebrew publisher and subscriber
sb.addPublish("speak", "string");
sb.addSubscribe("listen", "string");
// configure the spacebrew publisher and subscriber
sb.addPublish("speak", "string");
sb.addSubscribe("listen", "string");
// register the string message handler method
sb.onStringMessage(handleString);
// register the string message handler method
sb.onStringMessage(handleString);
// connect to cloud spacebrew server at "sandbox.spacebrew.cc"
sb.connect("sandbox.spacebrew.cc");
}
void loop() {
// monitor spacebrew connection for new data
sb.monitor();
// connected to spacebrew then send a string every 2 seconds
if ( sb.connected() ) {
// check if it is time to send a new message
if ( (millis() - last_time) > interval ) {
sb.send("speak", "is anybody out there?");
last_time = millis();
}
}
}
// handler method that is called whenever a new string message is received
void handleString (String route, String value) {
// print the message that was received
Serial.print("From ");
Serial.print(route);
Serial.print(", received msg: ");
Serial.println(value);
// connect to cloud spacebrew server at "sandbox.spacebrew.cc"
sb.connect("sandbox.spacebrew.cc");
}
void loop() {
// monitor spacebrew connection for new data
sb.monitor();
// connected to spacebrew then send a string every 2 seconds
if ( sb.connected() ) {
// check if it is time to send a new message
if ( (millis() - last_time) > interval ) {
sb.send("speak", "is anybody out there?");
last_time = millis();
}
}
}
// handler method that is called whenever a new string message is received
void handleString (String route, String value) {
// print the message that was received
Serial.print("From ");
Serial.print(route);
Serial.print(", received msg: ");
Serial.println(value);
}

View File

@ -8,26 +8,26 @@
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
Since this sketch uses Twilio to retrieve the SMS, you'll also need a valid
Since this sketch uses Twilio to retrieve the SMS, you'll also need a valid
Twilio account. You can create one for free at https://www.twilio.com.
The sketch needs your Twilio Account SID and Auth Token you get when you
register with Twilio. Make sure to use the Account SID and Auth Token from
The sketch needs your Twilio Account SID and Auth Token you get when you
register with Twilio. Make sure to use the Account SID and Auth Token from
your Twilio Dashboard (not your test credentials from the Dev Tools panel).
Normally, Twilio expects to contact a web site you provide to get a response
when an SMS message is received for your Twilio number. In this case, we
when an SMS message is received for your Twilio number. In this case, we
don't want to send any response (and we don't want to have to set up a web
site just to receive SMS messages.) You can use a URL that Twilio provides
for this purpose. When a message is received and sent to the Twilio "twimlets"
URL, it returns a code meaning "no response required." To set this up:
1. Log in to your Twilio account and go to this URL:
https://www.twilio.com/user/account/phone-numbers/incoming
2. Select the Twilio number you want to receive SMS messages at.
@ -40,7 +40,7 @@
https://www.twilio.com/help/faq/sms/how-can-i-receive-sms-messages-without-responding
4. Click the "Save Changes" button at the bottom of the page.
4. Click the "Save Changes" button at the bottom of the page.
Your account will now receive SMS messages, but won't send any responses.
@ -48,14 +48,14 @@
to the Internet.
Looking for another API? We've got over 100 in our Library!
This example code is in the public domain.
*/
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
@ -85,7 +85,7 @@ unsigned long lastSMSCheckTime = -SMS_CHECK_PERIOD;
// (we only need to process newer messages)
String lastSid;
// we'll be turning the LED built in to the Yun on and off
// we'll be turning the LED built in to the Yun on and off
// to simulate controlling some device. That LED is on pin 13.
int LED_PIN = 13;
@ -98,7 +98,7 @@ void setup() {
// for debugging, wait until a serial console is connected
delay(4000);
while(!Serial);
while (!Serial);
// tell the board to treat the LED pin as an output.
pinMode(LED_PIN, OUTPUT);
@ -109,7 +109,7 @@ void setup() {
// initialize the connection to the Linino processor.
Bridge.begin();
// Twilio will report old SMS messages. We want to
// Twilio will report old SMS messages. We want to
// ignore any existing control messages when we start.
Serial.println("Ignoring any existing control messages...");
checkForMessages(true);
@ -124,15 +124,15 @@ void loop()
// see if it's time to check for new SMS messages.
if (now - lastSMSCheckTime >= SMS_CHECK_PERIOD) {
// it's time to check for new messages
// save this time so we know when to check next
lastSMSCheckTime = now;
if (numRuns <= maxRuns) {
Serial.println("Checking for new SMS messages - Run #" + String(numRuns++));
// execute the choreo and don't ignore control messages.
// execute the choreo and don't ignore control messages.
checkForMessages(false);
} else {
Serial.println("Already ran " + String(maxRuns) + " times.");
@ -145,7 +145,7 @@ This function executes the Twilio > SMSMessages > ListMessages choreo
and processes the results.
If ignoreCommands is 'true', this function will read and process messages
updating 'lastSid', but will not actually take any action on any commands
updating 'lastSid', but will not actually take any action on any commands
found. This is so we can ignore any old control messages when we start.
If ignoreCommands is 'false', control messages WILL be acted on.
@ -156,7 +156,7 @@ void checkForMessages(bool ignoreCommands) {
TembooChoreo ListMessagesChoreo;
ListMessagesChoreo.begin();
// set Temboo account credentials
ListMessagesChoreo.setAccountName(TEMBOO_ACCOUNT);
ListMessagesChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -166,12 +166,12 @@ void checkForMessages(bool ignoreCommands) {
ListMessagesChoreo.setChoreo("/Library/Twilio/SMSMessages/ListMessages");
// set the choreo inputs
// see https://www.temboo.com/library/Library/Twilio/SMSMessages/ListMessages/
// see https://www.temboo.com/library/Library/Twilio/SMSMessages/ListMessages/
// for complete details about the inputs for this Choreo
// the first input is a your Twilio AccountSID
ListMessagesChoreo.addInput("AccountSID", TWILIO_ACCOUNT_SID);
// next is your Twilio Auth Token
ListMessagesChoreo.addInput("AuthToken", TWILIO_AUTH_TOKEN);
@ -179,24 +179,24 @@ void checkForMessages(bool ignoreCommands) {
ListMessagesChoreo.addInput("From", FROM_PHONE_NUMBER);
// Twilio can return information about up to 1000 messages at a time.
// we're only interested in the 3 most recent ones. Note that if
// this account receives lots of messages in quick succession,
// we're only interested in the 3 most recent ones. Note that if
// this account receives lots of messages in quick succession,
// (more than 3 per minute in this case), we might miss some control
// messages. But if we request too many messages, we might run out of
// messages. But if we request too many messages, we might run out of
// memory on the Arduino side of the Yun.
ListMessagesChoreo.addInput("PageSize", "3");
// We want the response in XML format to process with our
// We want the response in XML format to process with our
// XPath output filters.
ListMessagesChoreo.addInput("ResponseFormat", "xml");
// we don't want everything from the output, just the
// we don't want everything from the output, just the
// message IDs (the Sids) and the message texts
ListMessagesChoreo.addOutputFilter("sid", "Sid", "Response");
ListMessagesChoreo.addOutputFilter("text", "Body", "Response");
// tell the Choreo to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// tell the Choreo to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = ListMessagesChoreo.run();
@ -204,7 +204,7 @@ void checkForMessages(bool ignoreCommands) {
if (returnCode == 0) {
// Need a string to hold the list of message IDs.
String messageSids;
String messageSids;
// Need a string to hold the texts of the messages.
String messageTexts;
@ -214,8 +214,8 @@ void checkForMessages(bool ignoreCommands) {
// lists containing the Sids and texts of the messages
// from our designated phone number.
while(ListMessagesChoreo.available()) {
while (ListMessagesChoreo.available()) {
// output names are terminated with '\x1F' characters.
String name = ListMessagesChoreo.readStringUntil('\x1F');
name.trim();
@ -236,46 +236,46 @@ void checkForMessages(bool ignoreCommands) {
// done reading output, close the Choreo to free up resources.
ListMessagesChoreo.close();
// parse the comma delimited lists of messages and Sids
// parse the comma delimited lists of messages and Sids
processMessages(messageTexts, messageSids, ignoreCommands);
} else {
// a non-zero return code means there was an error
// read and print the error message
while(ListMessagesChoreo.available()) {
while (ListMessagesChoreo.available()) {
char c = ListMessagesChoreo.read();
Serial.print(c);
}
}
}
/*
/*
This function processes the lists of message texts and Sids.
If a message contains a comma as part of the
If a message contains a comma as part of the
message text, that message will be enclosed in double quotes
(") in the list. Example:
A message,"Hey, now",Another message text
If the message contains double quotes, it will be enclosed in
double quotes AND the internal quotes will be doubled.
double quotes AND the internal quotes will be doubled.
Example:
"Hi ""Sam"" the man", Led on
NOTE! We are assuming that Twilio returns more recent messages
first. This isn't officially documented by Twilio, but we've
first. This isn't officially documented by Twilio, but we've
not seen any other case.
'messageTexts' is a String containing a comma separated list of
message texts with commas and quotes escaped as described above.
'messageSids' is a String containing a comma separated list of
'messageSids' is a String containing a comma separated list of
message Sids. Sids should not contain embedded commas or quotes.
'ignoreCommands' is a boolean. 'true' means and control messages
will not be acted upon. 'false' means control messages will be
'ignoreCommands' is a boolean. 'true' means and control messages
will not be acted upon. 'false' means control messages will be
acted upon in the usual way.
*/
void processMessages(String messageTexts, String messageSids, bool ignoreCommands) {
@ -297,14 +297,14 @@ void processMessages(String messageTexts, String messageSids, bool ignoreCommand
// find the start of the next item in the list
i = messageSids.indexOf(',', sidsStart);
if (i >= 0) {
//extract a single Sid from the list.
sid = messageSids.substring(sidsStart, i);
sidsStart = i + 1;
// find the start of the next text in the list.
// find the start of the next text in the list.
// Note that we have to be prepared to handle embedded
// quotes and commans in the message texts.
// quotes and commans in the message texts.
// The standard Arduino String class doesn't handle
// this, so we have to write our own function to do it.
i = quotedIndexOf(messageTexts, ',', textsStart);
@ -314,12 +314,12 @@ void processMessages(String messageTexts, String messageSids, bool ignoreCommand
text = messageTexts.substring(textsStart, i);
textsStart = i + 1;
// process the Sid and text to see if it's a
// process the Sid and text to see if it's a
// control message.
ledUpdated = processMessage(sid, text, ignoreCommands);
}
} else {
// the last item in the lists won't have a comma at the end,
// so we have to handle them specially.
// Since we know this is the last item, we can just
@ -333,9 +333,9 @@ void processMessages(String messageTexts, String messageSids, bool ignoreCommand
// keep going until either we run out of list items
// or we run into a message we processed on a previous run.
} while ((i >=0) && (sid != lastSid));
// print what we've found to the serial monitor,
} while ((i >= 0) && (sid != lastSid));
// print what we've found to the serial monitor,
// just so we can see what's going on.
if (sid == lastSid) {
if (ledUpdated)
@ -359,17 +359,17 @@ A message with the text "LED ON" turns the LED on.
A message with the text "LED OFF" turns the LED off.
(Case is ignored.)
If 'ignoreCommands' is true, the actions described above will NOT
take place.
If 'ignoreCommands' is true, the actions described above will NOT
take place.
It also updates the 'lastSid' global variable when
It also updates the 'lastSid' global variable when
a control message is processed.
It returns 'true' if the message was a control message, and
'false' if it wasn't or if we've already processed this message.
*/
bool processMessage(String sid, String text, bool ignoreCommands) {
// a flag to indicate whether this was a control message or not
bool ledUpdated = false;
@ -377,7 +377,7 @@ bool processMessage(String sid, String text, bool ignoreCommands) {
if (sid != lastSid) {
if (text.equalsIgnoreCase("LED ON")) {
if (!ignoreCommands) {
//turn on the LED
digitalWrite(LED_PIN, HIGH);
@ -394,7 +394,7 @@ bool processMessage(String sid, String text, bool ignoreCommands) {
}
// If the LED state was updated, remember the Sid if this message.
if (ledUpdated)
if (ledUpdated)
lastSid = sid;
}
return ledUpdated;
@ -428,16 +428,16 @@ int quotedIndexOf(String s, char delim, int start) {
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can save it once,
Keeping your account information in a separate file means you can save it once,
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
*/

View File

@ -1,26 +1,26 @@
/*
GetYahooWeatherReport
Demonstrates making a request to the Yahoo! Weather API using Temboo from an Arduino Yun.
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
to the Internet.
Looking for another API to use with your Arduino Yun? We've got over 100 in our Library!
This example code is in the public domain.
*/
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
// the address for which a weather forecast will be retrieved
@ -32,10 +32,10 @@ int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo shou
void setup() {
Serial.begin(9600);
// for debugging, wait until a serial console is connected
delay(4000);
while(!Serial);
while (!Serial);
Bridge.begin();
}
@ -44,13 +44,13 @@ void loop()
{
// while we haven't reached the max number of runs...
if (numRuns <= maxRuns) {
// print status
Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "...");
// create a TembooChoreo object to send a Choreo request to Temboo
TembooChoreo GetWeatherByAddressChoreo;
// invoke the Temboo client
GetWeatherByAddressChoreo.begin();
@ -58,30 +58,30 @@ void loop()
GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT);
GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY);
// set the name of the choreo we want to run
GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress");
// set choreo inputs; in this case, the address for which to retrieve weather data
// the Temboo client provides standardized calls to 100+ cloud APIs
GetWeatherByAddressChoreo.addInput("Address", ADDRESS_FOR_FORECAST);
// add an output filter to extract the name of the city.
GetWeatherByAddressChoreo.addOutputFilter("city", "/rss/channel/yweather:location/@city", "Response");
// add an output filter to extract the current temperature
GetWeatherByAddressChoreo.addOutputFilter("temperature", "/rss/channel/item/yweather:condition/@temp", "Response");
// add an output filter to extract the date and time of the last report.
GetWeatherByAddressChoreo.addOutputFilter("date", "/rss/channel/item/yweather:condition/@date", "Response");
// run the choreo
// run the choreo
GetWeatherByAddressChoreo.run();
// when the choreo results are available, print them to the serial monitor
while(GetWeatherByAddressChoreo.available()) {
char c = GetWeatherByAddressChoreo.read();
while (GetWeatherByAddressChoreo.available()) {
char c = GetWeatherByAddressChoreo.read();
Serial.print(c);
}
GetWeatherByAddressChoreo.close();
@ -101,15 +101,15 @@ void loop()
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -1,33 +1,33 @@
/*
ReadATweet
Demonstrates retrieving the most recent Tweet from a user's home timeline
Demonstrates retrieving the most recent Tweet from a user's home timeline
using Temboo from an Arduino Yun.
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
In order to run this sketch, you'll need to register an application using
the Twitter dev console at https://dev.twitter.com. After creating the
app, you'll find OAuth credentials for that application under the "OAuth Tool" tab.
Substitute these values for the placeholders below.
the Twitter dev console at https://dev.twitter.com. After creating the
app, you'll find OAuth credentials for that application under the "OAuth Tool" tab.
Substitute these values for the placeholders below.
This example assumes basic familiarity with Arduino sketches, and that your Yun
This example assumes basic familiarity with Arduino sketches, and that your Yun
is connected to the Internet.
Want to use another social API with your Arduino Yun? We've got Facebook,
Want to use another social API with your Arduino Yun? We've got Facebook,
Google+, Instagram, Tumblr and more in our Library!
This example code is in the public domain.
*/
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
@ -43,10 +43,10 @@ int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo s
void setup() {
Serial.begin(9600);
// For debugging, wait until a serial console is connected.
delay(4000);
while(!Serial);
while (!Serial);
Bridge.begin();
}
void loop()
@ -54,14 +54,14 @@ void loop()
// while we haven't reached the max number of runs...
if (numRuns <= maxRuns) {
Serial.println("Running ReadATweet - Run #" + String(numRuns++));
TembooChoreo HomeTimelineChoreo;
// invoke the Temboo client.
// NOTE that the client must be reinvoked, and repopulated with
// appropriate arguments, each time its run() method is called.
HomeTimelineChoreo.begin();
// set Temboo account credentials
HomeTimelineChoreo.setAccountName(TEMBOO_ACCOUNT);
HomeTimelineChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -69,8 +69,8 @@ void loop()
// tell the Temboo client which Choreo to run (Twitter > Timelines > HomeTimeline)
HomeTimelineChoreo.setChoreo("/Library/Twitter/Timelines/HomeTimeline");
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Twitter/Timelines/HomeTimeline/
// for complete details about the inputs for this Choreo
@ -78,44 +78,44 @@ void loop()
HomeTimelineChoreo.addInput("Count", "1"); // the max number of Tweets to return from each request
HomeTimelineChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN);
HomeTimelineChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET);
HomeTimelineChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);
HomeTimelineChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);
HomeTimelineChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET);
// next, we'll define two output filters that let us specify the
// next, we'll define two output filters that let us specify the
// elements of the response from Twitter that we want to receive.
// see the examples at http://www.temboo.com/arduino
// for more on using output filters
// we want the text of the tweet
HomeTimelineChoreo.addOutputFilter("tweet", "/[1]/text", "Response");
// and the name of the author
HomeTimelineChoreo.addOutputFilter("author", "/[1]/user/screen_name", "Response");
// tell the Process to run and wait for the results. The
// return code will tell us whether the Temboo client
// tell the Process to run and wait for the results. The
// return code will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = HomeTimelineChoreo.run();
// a response code of 0 means success; print the API response
if(returnCode == 0) {
// a response code of 0 means success; print the API response
if (returnCode == 0) {
String author; // a String to hold the tweet author's name
String tweet; // a String to hold the text of the tweet
// choreo outputs are returned as key/value pairs, delimited with
// choreo outputs are returned as key/value pairs, delimited with
// newlines and record/field terminator characters, for example:
// Name1\n\x1F
// Value1\n\x1E
// Name2\n\x1F
// Value2\n\x1E
// Value2\n\x1E
// see the examples at http://www.temboo.com/arduino for more details
// we can read this format into separate variables, as follows:
while(HomeTimelineChoreo.available()) {
while (HomeTimelineChoreo.available()) {
// read the name of the output item
String name = HomeTimelineChoreo.readStringUntil('\x1F');
name.trim();
@ -131,13 +131,13 @@ void loop()
author = data;
}
}
Serial.println("@" + author + " - " + tweet);
} else {
// there was an error
// print the raw output from the choreo
while(HomeTimelineChoreo.available()) {
while (HomeTimelineChoreo.available()) {
char c = HomeTimelineChoreo.read();
Serial.print(c);
}
@ -159,15 +159,15 @@ void loop()
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -5,30 +5,30 @@
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
In order to run this sketch, you'll need to register an application using
the Twitter dev console at https://dev.twitter.com. Note that since this
the Twitter dev console at https://dev.twitter.com. Note that since this
sketch creates a new tweet, your application will need to be configured with
read+write permissions. After creating the app, you'll find OAuth credentials
for that application under the "OAuth Tool" tab. Substitute these values for
the placeholders below.
read+write permissions. After creating the app, you'll find OAuth credentials
for that application under the "OAuth Tool" tab. Substitute these values for
the placeholders below.
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
to the Internet.
Want to use another social API with your Arduino Yun? We've got Facebook,
Want to use another social API with your Arduino Yun? We've got Facebook,
Google+, Instagram, Tumblr and more in our Library!
This example code is in the public domain.
*/
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
@ -48,7 +48,7 @@ void setup() {
// for debugging, wait until a serial console is connected
delay(4000);
while(!Serial);
while (!Serial);
Bridge.begin();
}
@ -59,18 +59,18 @@ void loop()
if (numRuns <= maxRuns) {
Serial.println("Running SendATweet - Run #" + String(numRuns++) + "...");
// define the text of the tweet we want to send
String tweetText("My Arduino Yun has been running for " + String(millis()) + " milliseconds.");
TembooChoreo StatusesUpdateChoreo;
// invoke the Temboo client
// NOTE that the client must be reinvoked, and repopulated with
// appropriate arguments, each time its run() method is called.
StatusesUpdateChoreo.begin();
// set Temboo account credentials
StatusesUpdateChoreo.setAccountName(TEMBOO_ACCOUNT);
StatusesUpdateChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -80,26 +80,26 @@ void loop()
StatusesUpdateChoreo.setChoreo("/Library/Twitter/Tweets/StatusesUpdate");
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/
// see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/
// for complete details about the inputs for this Choreo
// add the Twitter account information
StatusesUpdateChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN);
StatusesUpdateChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET);
StatusesUpdateChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);
StatusesUpdateChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);
StatusesUpdateChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET);
// and the tweet we want to send
StatusesUpdateChoreo.addInput("StatusUpdate", tweetText);
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = StatusesUpdateChoreo.run();
// a return code of zero (0) means everything worked
if (returnCode == 0) {
Serial.println("Success! Tweet sent!");
Serial.println("Success! Tweet sent!");
} else {
// a non-zero return code means there was an error
// read and print the error message
@ -107,7 +107,7 @@ void loop()
char c = StatusesUpdateChoreo.read();
Serial.print(c);
}
}
}
StatusesUpdateChoreo.close();
// do nothing for the next 90 seconds
@ -124,15 +124,15 @@ void loop()
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -5,17 +5,17 @@
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
Since this sketch uses Gmail to send the email, you'll also need a valid
Google Gmail account. The sketch needs the username and password you use
Since this sketch uses Gmail to send the email, you'll also need a valid
Google Gmail account. The sketch needs the username and password you use
to log into your Gmail account - substitute the placeholders below for these values.
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
to the Internet.
Looking for another API to use with your Arduino Yun? We've got over 100 in our Library!
This example code is in the public domain.
@ -24,7 +24,7 @@
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
@ -41,14 +41,14 @@ const String GMAIL_PASSWORD = "xxxxxxxxxx";
const String TO_EMAIL_ADDRESS = "xxxxxxxxxx";
// a flag to indicate whether we've tried to send the email yet or not
boolean attempted = false;
boolean attempted = false;
void setup() {
Serial.begin(9600);
// for debugging, wait until a serial console is connected
delay(4000);
while(!Serial);
while (!Serial);
Bridge.begin();
}
@ -59,14 +59,14 @@ void loop()
if (!attempted) {
Serial.println("Running SendAnEmail...");
TembooChoreo SendEmailChoreo;
// invoke the Temboo client
// NOTE that the client must be reinvoked, and repopulated with
// appropriate arguments, each time its run() method is called.
SendEmailChoreo.begin();
// set Temboo account credentials
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -74,13 +74,13 @@ void loop()
// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
// see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
// for complete details about the inputs for this Choreo
// the first input is your Gmail email address.
// the first input is your Gmail email address.
SendEmailChoreo.addInput("Username", GMAIL_USER_NAME);
// next is your Gmail password.
SendEmailChoreo.addInput("Password", GMAIL_PASSWORD);
@ -89,17 +89,17 @@ void loop()
// then a subject line
SendEmailChoreo.addInput("Subject", "ALERT: Greenhouse Temperature");
// next comes the message body, the main content of the email
// next comes the message body, the main content of the email
SendEmailChoreo.addInput("MessageBody", "Hey! The greenhouse is too cold!");
// tell the Choreo to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// tell the Choreo to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = SendEmailChoreo.run();
// a return code of zero (0) means everything worked
if (returnCode == 0) {
Serial.println("Success! Email sent!");
Serial.println("Success! Email sent!");
} else {
// a non-zero return code means there was an error
// read and print the error message
@ -107,9 +107,9 @@ void loop()
char c = SendEmailChoreo.read();
Serial.print(c);
}
}
}
SendEmailChoreo.close();
// set the flag showing we've tried
attempted = true;
}
@ -123,15 +123,15 @@ void loop()
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -5,35 +5,35 @@
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
Since this sketch uses Twilio to send the SMS, you'll also need a valid
Since this sketch uses Twilio to send the SMS, you'll also need a valid
Twilio account. You can create one for free at https://www.twilio.com.
The sketch needs your Twilio phone number, along with
the Account SID and Auth Token you get when you register with Twilio.
Make sure to use the Account SID and Auth Token from your Twilio Dashboard
Make sure to use the Account SID and Auth Token from your Twilio Dashboard
(not your test credentials from the Dev Tools panel).
Also note that if you're using a free Twilio account, you'll need to verify
Also note that if you're using a free Twilio account, you'll need to verify
the phone number to which messages are being sent by going to twilio.com and following
the instructions under the "Numbers > Verified Caller IDs" tab (this restriction
doesn't apply if you have a paid Twilio account).
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
to the Internet.
Looking for another API to use with your Arduino Yun? We've got over 100 in our Library!
This example code is in the public domain.
*/
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
@ -55,14 +55,14 @@ const String TWILIO_NUMBER = "xxxxxxxxxx";
const String RECIPIENT_NUMBER = "xxxxxxxxxx";
// a flag to indicate whether we've attempted to send the SMS yet or not
boolean attempted = false;
boolean attempted = false;
void setup() {
Serial.begin(9600);
// for debugging, wait until a serial console is connected
delay(4000);
while(!Serial);
while (!Serial);
Bridge.begin();
}
@ -73,7 +73,7 @@ void loop()
if (!attempted) {
Serial.println("Running SendAnSMS...");
// we need a Process object to send a Choreo request to Temboo
TembooChoreo SendSMSChoreo;
@ -81,7 +81,7 @@ void loop()
// NOTE that the client must be reinvoked and repopulated with
// appropriate arguments each time its run() method is called.
SendSMSChoreo.begin();
// set Temboo account credentials
SendSMSChoreo.setAccountName(TEMBOO_ACCOUNT);
SendSMSChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -91,32 +91,32 @@ void loop()
SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS");
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/
// see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/
// for complete details about the inputs for this Choreo
// the first input is a your AccountSID
SendSMSChoreo.addInput("AccountSID", TWILIO_ACCOUNT_SID);
// next is your Auth Token
SendSMSChoreo.addInput("AuthToken", TWILIO_AUTH_TOKEN);
// next is your Twilio phone number
SendSMSChoreo.addInput("From", TWILIO_NUMBER);
// next, what number to send the SMS to
SendSMSChoreo.addInput("To", RECIPIENT_NUMBER);
// finally, the text of the message to send
SendSMSChoreo.addInput("Body", "Hey, there! This is a message from your Arduino Yun!");
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = SendSMSChoreo.run();
// a return code of zero (0) means everything worked
if (returnCode == 0) {
Serial.println("Success! SMS sent!");
Serial.println("Success! SMS sent!");
} else {
// a non-zero return code means there was an error
// read and print the error message
@ -124,11 +124,11 @@ void loop()
char c = SendSMSChoreo.read();
Serial.print(c);
}
}
}
SendSMSChoreo.close();
// set the flag indicatine we've tried once.
attempted=true;
attempted = true;
}
}
@ -140,15 +140,15 @@ void loop()
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -5,14 +5,14 @@
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
Since this sketch uses a Google spreadsheet, you'll also need a
Since this sketch uses a Google spreadsheet, you'll also need a
Google account: substitute the placeholders below for your Google account values.
This example assumes basic familiarity with Arduino sketches, and that your
This example assumes basic familiarity with Arduino sketches, and that your
Yun is connected to the Internet.
The columns in your spreadsheet must have labels for the Choreo to
@ -21,14 +21,14 @@
assumes there are two columns. The first column is the time (in milliseconds)
that the row was appended, and the second column is a sensor value.
In other words, your spreadsheet should look like:
Time | Sensor Value |
Time | Sensor Value |
------+-----------------
| |
NOTE that the first time you run this sketch, you may receive a warning from
Google, prompting you to authorize access from a 3rd party system.
Looking for another API to use with your Arduino Yun? We've got over 100 in our Library!
This example code is in the public domain.
@ -38,7 +38,7 @@
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information,
// as described in the footer comment below
// as described in the footer comment below
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
@ -57,17 +57,17 @@ const String SPREADSHEET_TITLE = "your-spreadsheet-title";
const unsigned long RUN_INTERVAL_MILLIS = 60000; // how often to run the Choreo (in milliseconds)
// the last time we ran the Choreo
// the last time we ran the Choreo
// (initialized to 60 seconds ago so the
// Choreo is run immediately when we start up)
unsigned long lastRun = (unsigned long)-60000;
unsigned long lastRun = (unsigned long) - 60000;
void setup() {
// for debugging, wait until a serial console is connected
Serial.begin(9600);
delay(4000);
while(!Serial);
while (!Serial);
Serial.print("Initializing the bridge...");
Bridge.begin();
@ -84,7 +84,7 @@ void loop()
// remember 'now' as the last time we ran the choreo
lastRun = now;
Serial.println("Getting sensor value...");
// get the value we want to append to our spreadsheet
@ -99,19 +99,19 @@ void loop()
// NOTE that the client must be reinvoked and repopulated with
// appropriate arguments each time its run() method is called.
AppendRowChoreo.begin();
// set Temboo account credentials
AppendRowChoreo.setAccountName(TEMBOO_ACCOUNT);
AppendRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
AppendRowChoreo.setAppKey(TEMBOO_APP_KEY);
// identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow)
AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow");
// set the required Choreo inputs
// see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/
// see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/
// for complete details about the inputs for this Choreo
// your Google username (usually your email address)
AppendRowChoreo.addInput("Username", GOOGLE_USERNAME);
@ -131,7 +131,7 @@ void loop()
AppendRowChoreo.addInput("RowData", rowData);
// run the Choreo and wait for the results
// The return code (returnCode) will indicate success or failure
// The return code (returnCode) will indicate success or failure
unsigned int returnCode = AppendRowChoreo.run();
// return code of zero (0) means success
@ -139,7 +139,7 @@ void loop()
Serial.println("Success! Appended " + rowData);
Serial.println("");
} else {
// return code of anything other than zero means failure
// return code of anything other than zero means failure
// read and display any error messages
while (AppendRowChoreo.available()) {
char c = AppendRowChoreo.read();
@ -151,7 +151,7 @@ void loop()
}
}
// this function simulates reading the value of a sensor
// this function simulates reading the value of a sensor
unsigned long getSensorValue() {
return analogRead(A0);
}
@ -164,15 +164,15 @@ unsigned long getSensorValue() {
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -1,28 +1,28 @@
/*
ToxicFacilitiesSearch
Demonstrates making a request to the Envirofacts API using Temboo from an Arduino Yun.
This example retrieves the names and addresses of EPA-regulated facilities in the
This example retrieves the names and addresses of EPA-regulated facilities in the
Toxins Release Inventory (TRI) database within a given zip code.
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
to the Internet.
Looking for another API to use with your Arduino Yun? We've got over 100 in our Library!
This example code is in the public domain.
*/
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
// the zip code to search for toxin-emitting facilities
String US_ZIP_CODE = "11215";
@ -32,10 +32,10 @@ int maxRuns = 10; // max number of times the Envirofacts FacilitiesSearch Chore
void setup() {
Serial.begin(9600);
// for debugging, wait until a serial console is connected
delay(4000);
while(!Serial);
while (!Serial);
Bridge.begin();
}
@ -43,7 +43,7 @@ void loop()
{
// while we haven't reached the max number of runs...
if (numRuns <= maxRuns) {
// print status
Serial.println("Running ToxicFacilitiesSearch - Run #" + String(numRuns++) + "...");
@ -54,26 +54,26 @@ void loop()
// NOTE that the client must be reinvoked and repopulated with
// appropriate arguments each time its run() method is called.
FacilitiesSearchByZipChoreo.begin();
// set Temboo account credentials
FacilitiesSearchByZipChoreo.setAccountName(TEMBOO_ACCOUNT);
FacilitiesSearchByZipChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
FacilitiesSearchByZipChoreo.setAppKey(TEMBOO_APP_KEY);
// identify the Temboo Library choreo to run (EnviroFacts > Toxins > FacilitiesSearchByZip)
FacilitiesSearchByZipChoreo.setChoreo("/Library/EnviroFacts/Toxins/FacilitiesSearchByZip");
// set choreo inputs; in this case, the US zip code for which to retrieve toxin release data
// the Temboo client provides standardized calls to 100+ cloud APIs
FacilitiesSearchByZipChoreo.addInput("Zip", US_ZIP_CODE);
// specify two output filters, to help simplify the Envirofacts API results.
// see the tutorials on using Temboo SDK output filters at http://www.temboo.com/arduino
FacilitiesSearchByZipChoreo.addOutputFilter("fac", "FACILITY_NAME", "Response");
FacilitiesSearchByZipChoreo.addOutputFilter("addr", "STREET_ADDRESS", "Response");
// run the choreo
// run the choreo
unsigned int returnCode = FacilitiesSearchByZipChoreo.run();
if (returnCode == 0) {
String facilities;
@ -83,7 +83,7 @@ void loop()
// the output filters we specified will return comma delimited
// lists containing the name and street address of the facilities
// located in the specified zip code.
while(FacilitiesSearchByZipChoreo.available()) {
while (FacilitiesSearchByZipChoreo.available()) {
String name = FacilitiesSearchByZipChoreo.readStringUntil('\x1F');
name.trim();
@ -97,8 +97,8 @@ void loop()
}
}
FacilitiesSearchByZipChoreo.close();
// parse the comma delimited lists of facilities to join the
// parse the comma delimited lists of facilities to join the
// name with the address and print it to the serial monitor
if (facilities.length() > 0) {
int i = -1;
@ -118,12 +118,12 @@ void loop()
address = addresses.substring(addressStart, i);
addressStart = i + 1;
}
if (i >= 0) {
printResult(facility, address);
}
}while (i >= 0);
} while (i >= 0);
facility = facilities.substring(facilityStart);
address = addresses.substring(addressStart);
printResult(facility, address);
@ -131,7 +131,7 @@ void loop()
Serial.println("No facilities found in zip code " + US_ZIP_CODE);
}
} else {
while(FacilitiesSearchByZipChoreo.available()) {
while (FacilitiesSearchByZipChoreo.available()) {
char c = FacilitiesSearchByZipChoreo.read();
Serial.print(c);
}
@ -157,15 +157,15 @@ void printResult(String facility, String address) {
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -4,9 +4,9 @@
Demonstrates sending a Facebook status update using Temboo from an Arduino Yun.
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
In order to run this sketch, you'll need to register an application using
@ -15,19 +15,19 @@
to use our OAuth Wizard (or OAuth Choreos) to obtain a Facebook access token.
Substitute your access token for the placeholder value of FACEBOOK_ACCESS_TOKEN below.
This example assumes basic familiarity with Arduino sketches, and that your Yun
This example assumes basic familiarity with Arduino sketches, and that your Yun
is connected to the Internet.
Want to use another social API with your Arduino Yun? We've got Twitter, Google+,
Want to use another social API with your Arduino Yun? We've got Twitter, Google+,
Instagram, Tumblr and more in our Library!
This example code is in the public domain.
This example code is in the public domain.
*/
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information,
// as described in the footer comment below
// as described in the footer comment below
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
@ -43,10 +43,10 @@ int maxRuns = 10; // the max number of times the Facebook SetStatus Choreo shou
void setup() {
Serial.begin(9600);
// For debugging, wait until a serial console is connected.
delay(4000);
while(!Serial);
while (!Serial);
Bridge.begin();
}
@ -56,19 +56,19 @@ void loop() {
// print status
Serial.println("Running UpdateFacebookStatus - Run #" + String(numRuns++) + "...");
// Define the status message we want to post on Facebook; since Facebook
// doesn't allow duplicate status messages, we'll include a changing value.
String statusMsg = "My Arduino Yun has been running for " + String(millis()) + " milliseconds!";
// define the Process that will be used to call the "temboo" client
// define the Process that will be used to call the "temboo" client
TembooChoreo SetStatusChoreo;
// invoke the Temboo client
// NOTE that the client must be reinvoked and repopulated with
// appropriate arguments each time its run() method is called.
SetStatusChoreo.begin();
// set Temboo account credentials
SetStatusChoreo.setAccountName(TEMBOO_ACCOUNT);
SetStatusChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -80,23 +80,23 @@ void loop() {
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/
// for complete details about the inputs for this Choreo
SetStatusChoreo.addInput("AccessToken", FACEBOOK_ACCESS_TOKEN);
SetStatusChoreo.addInput("AccessToken", FACEBOOK_ACCESS_TOKEN);
SetStatusChoreo.addInput("Message", statusMsg);
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = SetStatusChoreo.run();
// print the response code and API response.
Serial.println("Response code: " + String(returnCode));
// note that in this case, we're just printing the raw response from Facebook.
// see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino
// for information on how to filter this data
while(SetStatusChoreo.available()) {
// for information on how to filter this data
while (SetStatusChoreo.available()) {
char c = SetStatusChoreo.read();
Serial.print(c);
}
@ -107,7 +107,7 @@ void loop() {
Serial.println("Waiting...");
Serial.println("");
delay(30000); // wait 30 seconds between SetStatus calls
delay(30000); // wait 30 seconds between SetStatus calls
}
/*
@ -118,15 +118,15 @@ void loop() {
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -1,23 +1,23 @@
/*
UploadToDropbox
Demonstrates uploading a file to a Dropbox account using Temboo from an Arduino Yun.
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
You'll also need a valid Dropbox app and accompanying OAuth credentials.
To create a Dropbox app, visit https://www.dropbox.com/developers/apps and
You'll also need a valid Dropbox app and accompanying OAuth credentials.
To create a Dropbox app, visit https://www.dropbox.com/developers/apps and
do the following:
1. Create a "Dropbox API app"
2. Select "Files and datastores"
3. Select "Yes - my app only needs access to the files it creates."
Once you've created your app, follow the instructions at
Once you've created your app, follow the instructions at
https://www.temboo.com/library/Library/Dropbox/OAuth/ to run the Initialize and Finalize
OAuth Choreos. These Choreos complete the OAuth handshake and retrieve your Dropbox OAuth access tokens.
@ -25,14 +25,14 @@
to the Internet.
Looking for another API to use with your Arduino Yun? We've got over 100 in our Library!
This example code is in the public domain.
*/
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
@ -43,7 +43,7 @@
// your Dropbox app key, available on the Dropbox developer console after registering an app
const String DROPBOX_APP_KEY = "xxxxxxxxxx";
// your Dropbox app secret, available on the Dropbox developer console after registering an app
// your Dropbox app secret, available on the Dropbox developer console after registering an app
const String DROPBOX_APP_SECRET = "xxxxxxxxxx";
// your Dropbox access token, which is returned by the FinalizeOAuth Choreo
@ -57,10 +57,10 @@ boolean success = false; // a flag to indicate whether we've uploaded the file y
void setup() {
Serial.begin(9600);
// For debugging, wait until a serial console is connected.
delay(4000);
while(!Serial);
while (!Serial);
Bridge.begin();
}
@ -68,23 +68,23 @@ void loop()
{
// only try to upload the file if we haven't already done so
if (!success) {
Serial.println("Base64 encoding data to upload...");
// base64 encode the data to upload
String base64EncodedData = base64Encode("Hello, Arduino!");
Serial.println("Uploading data to Dropbox...");
// we need a Process object to send a Choreo request to Temboo
// we need a Process object to send a Choreo request to Temboo
TembooChoreo UploadFileChoreo;
// invoke the Temboo client
// NOTE that the client must be reinvoked and repopulated with
// appropriate arguments each time its run() method is called.
UploadFileChoreo.begin();
// set Temboo account credentials
UploadFileChoreo.setAccountName(TEMBOO_ACCOUNT);
UploadFileChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -92,7 +92,7 @@ void loop()
// identify the Temboo Library choreo to run (Dropbox > FilesAndMetadata > UploadFile)
UploadFileChoreo.setChoreo("/Library/Dropbox/FilesAndMetadata/UploadFile");
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Dropbox/FilesAndMetadata/UploadFile/
// for complete details about the inputs for this Choreo
@ -103,31 +103,31 @@ void loop()
// next, the root folder on Dropbox relative to which the file path is specified.
// to work with the Dropbox app you created earlier, this should be left as "sandbox"
// if your Dropbox app has full access to your files, specify "dropbox"
UploadFileChoreo.addInput("Root","sandbox");
UploadFileChoreo.addInput("Root", "sandbox");
// next, the Base64 encoded file data to upload
UploadFileChoreo.addInput("FileContents", base64EncodedData);
// finally, the Dropbox OAuth credentials defined above
UploadFileChoreo.addInput("AppSecret", DROPBOX_APP_SECRET);
UploadFileChoreo.addInput("AccessToken", DROPBOX_ACCESS_TOKEN);
UploadFileChoreo.addInput("AccessTokenSecret", DROPBOX_ACCESS_TOKEN_SECRET);
UploadFileChoreo.addInput("AppKey", DROPBOX_APP_KEY);
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = UploadFileChoreo.run();
// a return code of zero (0) means everything worked
if (returnCode == 0) {
Serial.println("Success! File uploaded!");
success = true;
Serial.println("Success! File uploaded!");
success = true;
} else {
// a non-zero return code means there was an error
Serial.println("Uh-oh! Something went wrong!");
}
// print out the full response to the serial monitor in all
// cases, just for debugging
while (UploadFileChoreo.available()) {
@ -148,42 +148,42 @@ void loop()
by calling a Temboo Utilities Choreo.
*/
String base64Encode(String toEncode) {
// we need a Process object to send a Choreo request to Temboo
TembooChoreo Base64EncodeChoreo;
// invoke the Temboo client
Base64EncodeChoreo.begin();
// set Temboo account credentials
Base64EncodeChoreo.setAccountName(TEMBOO_ACCOUNT);
Base64EncodeChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
Base64EncodeChoreo.setAppKey(TEMBOO_APP_KEY);
// we need a Process object to send a Choreo request to Temboo
TembooChoreo Base64EncodeChoreo;
// identify the Temboo Library choreo to run (Utilities > Encoding > Base64Encode)
Base64EncodeChoreo.setChoreo("/Library/Utilities/Encoding/Base64Encode");
// set choreo inputs
Base64EncodeChoreo.addInput("Text", toEncode);
// run the choreo
Base64EncodeChoreo.run();
// read in the choreo results, and return the "Base64EncodedText" output value.
// see http://www.temboo.com/arduino for more details on using choreo outputs.
while(Base64EncodeChoreo.available()) {
// read the name of the output item
String name = Base64EncodeChoreo.readStringUntil('\x1F');
name.trim();
// invoke the Temboo client
Base64EncodeChoreo.begin();
// read the value of the output item
String data = Base64EncodeChoreo.readStringUntil('\x1E');
data.trim();
// set Temboo account credentials
Base64EncodeChoreo.setAccountName(TEMBOO_ACCOUNT);
Base64EncodeChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
Base64EncodeChoreo.setAppKey(TEMBOO_APP_KEY);
if(name == "Base64EncodedText") {
return data;
}
// identify the Temboo Library choreo to run (Utilities > Encoding > Base64Encode)
Base64EncodeChoreo.setChoreo("/Library/Utilities/Encoding/Base64Encode");
// set choreo inputs
Base64EncodeChoreo.addInput("Text", toEncode);
// run the choreo
Base64EncodeChoreo.run();
// read in the choreo results, and return the "Base64EncodedText" output value.
// see http://www.temboo.com/arduino for more details on using choreo outputs.
while (Base64EncodeChoreo.available()) {
// read the name of the output item
String name = Base64EncodeChoreo.readStringUntil('\x1F');
name.trim();
// read the value of the output item
String data = Base64EncodeChoreo.readStringUntil('\x1E');
data.trim();
if (name == "Base64EncodedText") {
return data;
}
}
}
/*
@ -194,15 +194,15 @@ String base64Encode(String toEncode) {
by inserting your own Temboo account name and app key information. The contents of the file should
look like:
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
You can find your Temboo App Key information on the Temboo website,
You can find your Temboo App Key information on the Temboo website,
under My Account > Application Keys
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/

View File

@ -1,41 +1,41 @@
/*
Temperature web interface
This example shows how to serve data from an analog input
This example shows how to serve data from an analog input
via the Arduino Yún's built-in webserver using the Bridge library.
The circuit:
* TMP36 temperature sensor on analog pin A1
* SD card attached to SD card slot of the Arduino Yún
Prepare your SD card with an empty folder in the SD root
named "arduino" and a subfolder of that named "www".
This will ensure that the Yún will create a link
Prepare your SD card with an empty folder in the SD root
named "arduino" and a subfolder of that named "www".
This will ensure that the Yún will create a link
to the SD to the "/mnt/sd" path.
In this sketch folder is a basic webpage and a copy of zepto.js, a
In this sketch folder is a basic webpage and a copy of zepto.js, a
minimized version of jQuery. When you upload your sketch, these files
will be placed in the /arduino/www/TemperatureWebPanel folder on your SD card.
You can then go to http://arduino.local/sd/TemperatureWebPanel
to see the output of this sketch.
You can remove the SD card while the Linux and the
You can remove the SD card while the Linux and the
sketch are running but be careful not to remove it while
the system is writing to it.
created 6 July 2013
by Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/TemperatureWebPanel
*/
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
#include <YunClient.h>
// Listen on default port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
@ -47,7 +47,7 @@ void setup() {
Serial.begin(9600);
// Bridge startup
pinMode(13,OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);
@ -66,7 +66,7 @@ void setup() {
// get the time that this sketch started:
Process startTime;
startTime.runShellCommand("date");
while(startTime.available()) {
while (startTime.available()) {
char c = startTime.read();
startString += c;
}
@ -89,16 +89,16 @@ void loop() {
Process time;
time.runShellCommand("date");
String timeString = "";
while(time.available()) {
while (time.available()) {
char c = time.read();
timeString += c;
}
Serial.println(timeString);
int sensorValue = analogRead(A1);
// convert the reading to millivolts:
float voltage = sensorValue * (5000/ 1024);
float voltage = sensorValue * (5000 / 1024);
// convert the millivolts to temperature celsius:
float temperature = (voltage - 500)/10;
float temperature = (voltage - 500) / 10;
// print the temperature:
client.print("Current time on the Yún: ");
client.println(timeString);

View File

@ -1,16 +1,16 @@
/*
Time Check
Time Check
Gets the time from the linino processor via Bridge
then parses out hours, minutes and seconds for the Arduino
using an Arduino Yún.
using an Arduino Yún.
created 27 May 2013
modified 21 June 2013
By Tom Igoe
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/TimeCheck
*/
@ -24,14 +24,14 @@ int lastSecond = -1; // need an impossible value for comparison
void setup() {
Bridge.begin(); // initialize Bridge
Serial.begin(9600); // initialize serial
while(!Serial); // wait for Serial Monitor to open
Serial.begin(9600); // initialize serial
while (!Serial); // wait for Serial Monitor to open
Serial.println("Time Check"); // Title of sketch
// run an initial date process. Should return:
// hh:mm:ss :
if (!date.running()) {
if (!date.running()) {
date.begin("date");
date.addParameter("+%T");
date.run();
@ -40,10 +40,10 @@ void setup() {
void loop() {
if(lastSecond != seconds) { // if a second has passed
if (lastSecond != seconds) { // if a second has passed
// print the time:
if (hours <= 9) Serial.print("0"); // adjust for 0-9
Serial.print(hours);
Serial.print(hours);
Serial.print(":");
if (minutes <= 9) Serial.print("0"); // adjust for 0-9
Serial.print(minutes);
@ -52,7 +52,7 @@ void loop() {
Serial.println(seconds);
// restart the date process:
if (!date.running()) {
if (!date.running()) {
date.begin("date");
date.addParameter("+%T");
date.run();
@ -60,24 +60,24 @@ void loop() {
}
//if there's a result from the date process, parse it:
while (date.available()>0) {
while (date.available() > 0) {
// get the result of the date process (should be hh:mm:ss):
String timeString = date.readString();
String timeString = date.readString();
// find the colons:
int firstColon = timeString.indexOf(":");
int secondColon= timeString.lastIndexOf(":");
int secondColon = timeString.lastIndexOf(":");
// get the substrings for hour, minute second:
String hourString = timeString.substring(0, firstColon);
String minString = timeString.substring(firstColon+1, secondColon);
String secString = timeString.substring(secondColon+1);
String hourString = timeString.substring(0, firstColon);
String minString = timeString.substring(firstColon + 1, secondColon);
String secString = timeString.substring(secondColon + 1);
// convert to ints,saving the previous second:
hours = hourString.toInt();
minutes = minString.toInt();
lastSecond = seconds; // save to do a time comparison
seconds = secString.toInt();
}
}
}

View File

@ -1,6 +1,6 @@
/*
WiFi Status
WiFi Status
This sketch runs a script called "pretty-wifi-info.lua"
installed on your Yún in folder /usr/bin.
It prints information about the status of your wifi connection.
@ -11,22 +11,22 @@
created 18 June 2013
By Federico Fissore
This example code is in the public domain.
http://arduino.cc/en/Tutorial/YunWiFiStatus
*/
#include <Process.h>
void setup() {
Serial.begin(9600); // initialize serial communication
while(!Serial); // do nothing until the serial monitor is opened
while (!Serial); // do nothing until the serial monitor is opened
Serial.println("Starting bridge...\n");
pinMode(13,OUTPUT);
digitalWrite(13, LOW);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin(); // make contact with the linux processor
digitalWrite(13, HIGH); // Led on pin 13 turns on when the bridge is ready
@ -38,15 +38,15 @@ void loop() {
wifiCheck.runShellCommand("/usr/bin/pretty-wifi-info.lua"); // command you want to run
// while there's any characters coming back from the
// while there's any characters coming back from the
// process, print them to the serial monitor:
while (wifiCheck.available() > 0) {
char c = wifiCheck.read();
Serial.print(c);
}
Serial.println();
delay(5000);
}

View File

@ -1,15 +1,15 @@
/*
Xively sensor client with Strings
Xively sensor client with Strings
This sketch connects an analog sensor to Xively,
using an Arduino Yún.
using an Arduino Yún.
created 15 March 2010
updated 27 May 2013
by Tom Igoe
http://arduino.cc/en/Tutorial/YunXivelyClient
*/
@ -21,7 +21,7 @@
NOTE: passwords.h is not included with this repo because it contains my passwords.
You need to create it for your own version of this application. To do so, make
a new tab in Arduino, call it passwords.h, and include the following variables and constants:
#define APIKEY "foo" // replace your pachube api key here
#define FEEDID 0000 // replace your feed ID
#define USERAGENT "my-project" // user agent is the project name
@ -38,7 +38,7 @@ void setup() {
Bridge.begin();
Serial.begin(9600);
while(!Serial); // wait for Network Serial to open
while (!Serial); // wait for Network Serial to open
Serial.println("Xively client");
// Do a first update immediately
@ -94,14 +94,14 @@ void sendData() {
xively.addParameter("--data");
xively.addParameter(dataString);
xively.addParameter("--header");
xively.addParameter(apiString);
xively.addParameter(apiString);
xively.addParameter(url);
xively.run();
Serial.println("done!");
// If there's incoming data from the net connection,
// send it out the Serial:
while (xively.available()>0) {
while (xively.available() > 0) {
char c = xively.read();
Serial.write(c);
}

View File

@ -1,35 +1,35 @@
/*
Arduino Yun USB-to-Serial
Allows you to use the Yun's 32U4 processor as a
serial terminal for the linino processor.
Upload this to an Arduino Yun via serial (not WiFi)
Upload this to an Arduino Yun via serial (not WiFi)
then open the serial monitor at 115200 to see the boot process
of the linino processor. You can also use the serial monitor
as a basic command line interface for the linino processor using
as a basic command line interface for the linino processor using
this sketch.
From the serial monitor the following commands can be issued:
'~' followed by '0' -> Set the UART speed to 57600 baud
'~' followed by '1' -> Set the UART speed to 115200 baud
'~' followed by '2' -> Set the UART speed to 250000 baud
'~' followed by '3' -> Set the UART speed to 500000 baud
'~' followeb by '~' -> Sends the bridge's shutdown command to
obtain the console.
The circuit:
* Arduino Yun
created March 2013
by Massimo Banzi
modified by Cristian Maglie
This example code is in the public domain.
http://arduino.cc/en/Tutorial/YunSerialTerminal
*/
@ -75,8 +75,8 @@ void loop() {
commandMode = false; // in all cases exit from command mode
}
}
if (Serial1.available()) { // got anything from Linino?
char c = (char)Serial1.read(); // read from Linino
if (Serial1.available()) { // got anything from Linino?
char c = (char)Serial1.read(); // read from Linino
Serial.write(c); // write to USB-serial
}
}