Hello i am trying to set delay from processing knob. But when i set the delay on the processing knob the LED never goes off it stays ON forever .
This is my arduino code:
int theValue;
int theValue1;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
while(Serial.available() >0);
char val=Serial.read();
switch(val)
{
case 'c':
theValue=Serial.read();
break;
case 'd':
theValue1=Serial.read();
break;
case 'r':
digitalWrite(13,HIGH);
delay(theValue);
digitalWrite(13,LOW);
delay(theValue1);
break;
}
}
This is my processing code:
import controlP5.*;
ControlP5 cp5a;
ControlP5 cp5b;
ControlP5 cp5c;
Knob myKnobA;
Knob myKnobB;
float n,n1;
import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
void setup()
{
size(400,600);
noStroke();
String portName = Serial.list()[1]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 9600);
cp5a = new ControlP5(this);
cp5a.addButton("Blink")
.setValue(0)
.setPosition(100,100)
.setSize(200,19)
;
cp5b=new ControlP5(this);
myKnobA = cp5b.addKnob("knobON")
.setRange(0,1000)
.setValue(50)
.setPosition(150,200)
.setRadius(50)
.setDragDirection(Knob.VERTICAL)
;
cp5c=new ControlP5(this);
myKnobB = cp5b.addKnob("knobOFF")
.setRange(0,1000)
.setValue(50)
.setPosition(150,360)
.setRadius(50)
.setDragDirection(Knob.VERTICAL)
;
}
void draw()
{
background(0);
}
public void Blink(){
myPort.write('r');
}
public void knobON(int theValue){
myPort.write('c');
myPort.write(theValue);
}
public void knobOFF(int theValue1){
myPort.write(298);
myPort.write(theValue1);
}
Thank you.