We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I am trying to use 3 different servos with 3 sliders using ControlP5.
The sketch should know which slider (servo) it is and which direction
(open or closed) since I need to send that information to Arduino.
So far, processing just displays the values within saying which slider
(servo) has moved. Would it be possible to assign a character for each
slider? Then, Arduino would check the first character to see which servo
it is moving and which direction, e.g., V1--V servo going clockwise, or
A-1--A servo going counter-clockwise.
If someone could give me a hint, that would be greatly appreciated.
Thanks.
Lawrence
import processing.serial.*; // Import processing serial library
import controlP5.*; // Import controlP5 library
Serial serial; // Create serial object
ControlP5 cp5; // Create ControlP5 object
void setup()
{
int V = 0;
int A = 0;
int D = 0;
size(720,480); // Size of window
smooth(); // Anti-aliased edges
cp5 = new ControlP5(this); // Create new cp5 object
PFont font = createFont("ArialMT",20);
cp5.addSlider("V")
.setLabel("V Valve")
.setPosition(100,100)
.setWidth(200)
.setHeight(20)
.setRange(-1,1)
.setValue(0)
.setNumberOfTickMarks(3)
.setSliderMode(Slider.FLEXIBLE)
;
cp5.addSlider("A")
.setLabel("A Valve")
.setPosition(100,200)
.setWidth(200)
.setHeight(20)
.setRange(-1,1)
.setValue(0)
.setNumberOfTickMarks(3)
.setSliderMode(Slider.FLEXIBLE)
;
cp5.addSlider("D")
.setLabel("D Valve")
.setPosition(100,300)
.setWidth(200)
.setHeight(20)
.setRange(-1,1)
.setValue(0)
.setNumberOfTickMarks(3)
.setSliderMode(Slider.FLEXIBLE)
;
// Set texts for controlling servomotors
cp5.addTextfield("Closed")
.setPosition(100,350)
.setSize(100,1)
.setFont(font)
.setFocus(true)
.setColor(color(255,0,0))
.setAutoClear(false)
;
cp5.addTextfield("Stop")
.setPosition(192,350)
.setSize(100,1)
.setFont(font)
.setFocus(true)
.setColor(color(255,0,0))
.setAutoClear(false)
;
cp5.addTextfield("Open")
.setPosition(290,350)
.setSize(10,1)
.setFont(font)
.setFocus(true)
.setColor(color(255,0,0))
.setAutoClear(false)
;
}
void draw()
{
background(0); // Set background color to black
}
void controlEvent(ControlEvent c)
{
println(c.getValue()); // Display value of sliders and toggle
}
Answers
I don't get what you are asking. but I interpret it as you want to send the data to arduino.. you use .write to send data..
and for the arduino it would be somthing like. but i dont have an arduino so cant rly test anything, but i dont see why it would not work.