Hardware Reference
In-Depth Information
Start by combining the
list of global variables
from both sketches. Here's what it
should look like.
Try It
/*
Cat webcam uploader/emailer
Context: Processing
takes a webcam image continually, uploads it, and
mails you when it receives a serial string above a given value
*/
// import the libraries you need: Network, serial, video:
import processing.serial.*;
import processing.video.*;
import processing.net.*;
Serial myPort; // the serial port
float sensorValue = 0; // the value from the sensor
float prevSensorValue = 0; // previous value from the sensor
int threshold = 250; // above this number, the cat is on the mat.
int currentTime = 0; // the current time as a single number
int lastMailTime = 0; // last minute you sent a mail
int mailInterval = 60; // minimum seconds between mails
String mailUrl = "http://www.example.com/cat-script.php";
int lastPictureTime = 0; // last minute you sent a picture
int pictureInterval = 10; // minimum seconds between pictures
Capture myCam; // camera capture library instance
String fileName = "catcam.jpg"; // file name for the picture
// location on your server for the picture script:
String pictureScriptUrl = "/save2web.php";
String boundary = "----H4rkNrF"; // string boundary for the POST request
Client thisClient; // instance of the net library
8
Now combine the setup() methods
like so.
void setup() {
size(400,300);
// list all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my Mac is always my
// Arduino, so I open Serial.list()[0]. Open whatever port you're using
// (the output of Serial.list() can help; they are listed in order
// starting with the one that corresponds to [0]).
myPort = new Serial(this, Serial.list()[0], 9600);
// read bytes into a buffer until you get a newline (ASCII 10):
myPort.bufferUntil('\n');
ยป
 
Search WWH ::




Custom Search