We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm novice at using Processing.
In my code I want to change the background to white when the capacitive sensor is held down, and then back to black when the sensor is released.
I have attempted at writing this code in both capacitive sensor code in Arduino, however when I run my code in Processing nothing is shown or changes.
Any help would be greatly appreciated.
MY ARDUINO CODE IS BELLOW
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);
void setup(){
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);
Serial.begin(9600);
}
void loop(){
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
Serial.println(total1);
Serial.print(",");
delay(10);
}
MY PROCESSING CODE IS BELLOW
import processing.serial.*;
int touch1Value = 0;
int threshold = 30;
Serial myPort;
void setup(){
size (500,500);
myPort = new Serial(this, Serial.list()[1], 9600);
myPort.bufferUntil('\n');
}
void draw(){
background (0);
println("touch1Value:"+touch1Value);
if (touch1Value == 1){
background (255,255,255);
}
}
void serialEvent(Serial myPort){
String inString = myPort.readStringUntil('\n');
if (inString != null){
inString = trim (inString);
float[] touches = float (split(inString, ","));
if (touches.length >=1){
touch1Value = touches[0] >= threshold ? 1: 0;
}
}
}
Answers
Edit your post, select the code block and hit ctrl+o and make sure there is an empty line above and below your code.
Kf
continued here: https://forum.processing.org/two/discussion/21748/help-needed-getting-processing-to-open-video-files
closing this