I am currently doing a project using conductive paint and an arduino and i have it working using the capacitive sensor, so when its not being touched i see "0's" in the serial port but then when it is touched i get a reading of "59's" and "60's". what i want to do is when its touched i want is to trigger playing a video on a computer. I am new to arduino and processing so i am just wondering how to go about doing this if it is possible? thanks ![]()
If you want to play the video on a computer then you need to have some way of communicating with the computer to signal that it should start/stop playing. I am not familiar with Processing, but from other questions here I know that it can communicate using a serial port so that may be the simplest way of achieving what you want.
Read the sensor using the Arduino then send a message via the Serial interface indicating the required action. The message can be explicit, perhaps "play" or "stop" or could be as simple as 1 or 0. In Processing, when the message is received decode it and take the corresponding action.
All of this sounds reasonably simple if you know what you are doing and if Processing can initiate the playing of a video (I don't know). I suggest that you start with the Arduino end of things and print a message to the Serial monitor when the capacitive input changes. Note that it is important to act on changes to state rather than its current state to avoid repetitive triggering of actions. The StateChangeDetection example in the Arduino IDE will show you how to do this.
Im still quite new to this but i figure in processing its using an if statement to trigger a video to play if the number in the serial port is over a certain number i could be wrong but thats how i would approach it in processing. But my first issue is getting the capsensitive library that i use to make the paint touch sensitive in arduino to be used in processing?
my first issue is getting the capsensitive library that i use to make the paint touch sensitive in arduino
when its not being touched i see "0's" in the serial port but then when it is touched i get a reading of "59's" and "60's"
Start by posting the code that produced these results.
This is my code to get the number to change from 0 in the serial port to 59 & 60 in arduino what i want to do is bring it into processing but i am unsure how to go about getting the capacitive sensor to work in processing and then with the touch sensor depending of which one you touch i would like it to trigger a video to play.
#include <CapacitiveSensor.h>
CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4);
CapacitiveSensor cs_2_5 = CapacitiveSensor(2,5);
void setup()
{ Serial.begin(9600); }
void loop()
{ long total1 = cs_2_4.capacitiveSensor(30);
long total2 = cs_2_5.capacitiveSensor(30);
Serial.print("X");
Serial.print(",");
Serial.print(total1);
Serial.print(",");
Serial.println();
Serial.print("Y");
Serial.print(",");
Serial.print(total2);
Serial.print(",");
Serial.println();
delay(100);
}
i am unsure how to go about getting the capacitive sensor to work in processing
Can I be clear ? It sounds like you don't want to use the Arduino to read the sensor but want to read it using Processing. Is that correct ?
Yes as i heard its easier to trigger videos through processing. but its getting the touch sensitive conductive paint to work in processing. i think i might have gotten the processing and arduino working together by using this code in processing:
import processing.serial.*;
Serial myPort;
String val;
void setup(){
size(400,400);
String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 9600);
}
void draw()
{
if ( myPort.available() > 0)
{ // If data is available,
val = myPort.readStringUntil('\n'); // read it and store it in val
}
println(val); //print it out in the console
}
however i am unsure how to get the conductive paint working in processing?
I could be going about this all wrong or in a more difficult way but i appreciate your help ![]()
i think i might have gotten the processing and arduino working together by using this code in processing:
If that Processing code prints the value sent by the Arduino then you don't need to
get the conductive paint working in processing
Just check the value in Processing and execute the appropriate commands to play/stop the video.