Webcam snapshot when button is pressed?

Hello all,

I'm totally new to both processing and microcontrollers. I got my first Arduino today for a new project I'm working on, and it only needs to do one very simple task. Problem is, I can't seem to find how to do this anywhere on the internet. Every result that comes up is way too advanced.

See, the only thing I need is that when a user presses a button hooked to the Arduino, processing gets a signal to take and save a webcam picture. (Webcam is hooked up to the computer)

Sorry if I'm wasting your time with such a simple question, but like I said, I couldn't find a sketch for this anywhere. Does anybody have a simple Processing sketch that can do this?

Thanks a bunch!

Did you check the utorials yet? This is a good place to start: http://arduino.cc/en/Tutorial/Button and http://arduino.cc/en/Tutorial/DigitalReadSerial

you can also find sample code in a subdir where the Arduino code is installed.

~ arduino-0021\examples\2.Digital\Button

Yes, I got as far as that, but seeing how I have no former experience in programming I don’t know how to integrate that command in my Processing sketch. The Arduino is already configured to communicate with Processing with Firmata.

What I need is to replace this command:

void mousePressed(){
saveFrame("####.jpg");

With a command that tells Processing that a button is pressed on the Arduino.

What I need is to replace this command:

void mousePressed(){ saveFrame("####.jpg");

With a command that tells Processing that a button is pressed on the Arduino.

This might be helpful, then. http://www.arduino.cc/playground/Interfacing/Processing

You actually have to have Processing ask the Arduino if the button is pressed, but that's easy to do in the draw() function.

So if I’m correct I should take this piece of code

void draw(){
m.update();//update the camera view
m.imageCopy(pixels);//draw image to stage
updatePixels();

And somehow integrate that with something like this

void draw()
{
if ( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
}
background(255); // Set background to white
if (val == 0) { // If the serial value is 0,
fill(0); // set fill to black
}
else { // If the serial value is not 0,
fill(204); // set fill to light gray
}
rect(50, 50, 100, 100);
}

Right?

Without knowing what myPort and m are, it’s hard to say what you need to do.

Presumably, m is the camera object. myPort looks like it might be a serial port object.

You need to, prior to setup, create an Arduino instance, myArduino. Then, in draw(), call myArduino.digitalRead(pinNum), where pinNum is the number of the pin that the switch is attached to.

If myArduino.digitalRead() returns Arduino.HIGH, take the picture.