Linking a Capacitive Sensor with a sequence of images on Processing

Hi everyone,

For this project I want an object (with a capacitive sensor inside of it like a foil) to trigger a sequence of images (one at a time) on Processing when the object is touched. I want the Capacitive Sensor to have a clean reading so when the Capacitive sensor isn't being touched at all no images come up but when it is touched images come up. So initially 1 touch=1 image. Could somebody help me with the code that I would need for this on Arduino and Processing.

This is the code I am working off of atm, this is for the Arduino project 'Touchy Feely Lamp'. It would be super helpful if I had some help with what I need to add to the code so that it is relevant with this project.

//Import a library from the Arduino folder
#include <CapacitiveSensor.h>
//Select the two pins that will act as a capacitor
CapacitiveSensor capSensor = CapacitiveSensor(4,2);
//Insert the minimum value provided by the sensor to detect the touch
int threshold = 1000;
const int ledPin = 12;

void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}

void loop() {
//Read the sensor value
long sensorValue = capSensor.capacitiveSensor(30);
Serial.println(sensorValue);
//Touch detected
if (sensorValue > threshold) {
//Turn on the led
digitalWrite(ledPin, HIGH);
}
//Touch undetected
else {
//Turn off the led
digitalWrite(ledPin, LOW);
}
delay(10);
}

I know I would have to get rid off the LED and then add code which states that when the cap sensor is touched processing reads it and an image pops up. We're stuggling to find a code for processing too.

Any help would be really appreciated!!
Thank you

why do you need an Arduino at all ?

Seems like you only need a "1 button" mouse or "1 key" keyboard for your PC to drive the PC program ?

(and an Arduino can act as a keyboard or mouse if you select the right one)


Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

if (sensorValue > threshold) {
//Turn on the led
digitalWrite(ledPin, HIGH);
}
//Touch undetected
else {
//Turn off the led
digitalWrite(ledPin, LOW);
}

Instead of turning a pin on or off, you need to tell Processing to do something. I would have thought that that was obvious. Since Processing will be on the other end of the serial port, use

   Serial.println("Yo, Processing, show some image");

or

   Serial.println("Yo, Processing, hide the women and booze");

Or whatever you have programmed Processing to expect.

What Processing does is up to you. This isn't the Processing forum.