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