i have been trying to set Builtin LED frequency from arduino and turn it on and off .
I have created an interface with knobs and buttons in processing . I want to set delay between ON and OFF with 1 knob and OFF and ON delay with another knob . And button blinks the led at given frequency
In arduino i have tried something like this :
if(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;
}
}
In the processing :
public void Blink(){
myPort.write('r');
}
public void knobON(int theValue){
myPort.write('c');
myPort.write(theValue);
}
public void knobOFF(int theValue1){
myPort.write('d');
myPort.write(theValue1);
}
Can you help me on what should i do ?
char
over serial? Why not send an number, i.e. integer?