We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi here is my code:
import processing.serial.*; //imports serail library
import cc.arduino.*; //imports arduino library so I don't have to use arduino IDE
import controlP5.*; //Part of processing library
Arduino arduino;
ControlP5 cp5;
Slider Servo1;
void setup()
{
size(950, 900);
println(Arduino.list()); //sends data to serial port for arduino
arduino = new Arduino(this, Arduino.list()[0], 57600); //sets COMM Port Baud Rate
cp5 = new ControlP5(this); //dynamic variable of control class
arduino.pinMode(3, Arduino.SERVO); //sets this output pin for byte transfer
Servo1 = cp5.addSlider(".").setRange(0,180).setValue(90).setPosition(110,134).setSize(270,25).setNumberOfTickMarks(270).setLabelVisible(true).setColorForeground(color(102,102,102)).setColorBackground(color(255,153,0)).setColorActive(color(102,102,102));
}
void draw()
{
//will fill alter
background(color(51,102,153)); //background of GUI color in RGB format
arduino.servoWrite(3, int(Servo1.getValue())); //get value from slider and write info to the pins
textSize(50);
text("Robot Arm", 300, 75); //Title
textSize(25);
text("Finger", 20, 125); //labels for each servo
textSize(18);
text("[Pin 3]", 25, 150); //Labels for the pins each servo is connected to
}
Even though its long its simple. So basically this creates a graphical user interface with sliders that are sending data to pin 3 on my arduino UNO. Now by default the servos are at 90 degrees, so you move the slider left or right an the servo moves accordingly. My issue is the code was working on my servo one week ago, and now for some reason when I hook up my UNO to the servo and run the code, it uploads successfully but when you move the sliders on the interface, the servo does not move. Its like its not getting the data?
I tried a sample sweep program on the arduio website using the REGULAR IDE not processing IDE, an the sweep works fine. So I know its not the board, servos, or usb port that is an issue? Any ideas?
I am using processing version 3.2.3 Also if you can, run the code an hook up a small servo like a vilros SG90 and see if it works
Answers
Do you get any errors?
Maybe try using some print statements in your code and see what data are you receiving. Also make sure you are talking to the right COM port.
Kf
No errors from the processing code, it even says uploads successfully or something like that. Also I am using comm 3, an I tried comm 4 an same thing. I don't understand why its not sending the data? Also when I uploaded the sample sweep from the Arduino IDE, I went back to Processing IDE an uploaded the code you see above to see if it would work again. It uploaded to the board BUT, the code from the Arduino IDE was still running on the board when it should've been overwritten by the processing code??? I know the Arduino code was still running because I am using the same pins to send data on both Arduino IDE an Processing IDE.
I don't think you can have the Arduino serial monitor and the Processing running together. First thing, first, if you have it running and reading data from the monitor, then your arduino code is working fine. The next step is to check the received data in Processing. Also you should know what COM port your arduino is using. If you open the device manager and keep an eye on your serial COM ports, if you unplug your arduino and then you plug it back in after few seconds, you should see your Arduino connection being recognized as the computer creates a new COM port dedicated to your unit.
Kf
They are both using the same com port this has been verified. Also the arduino IDE was not running the same time as the Processing IDE. When I was done with my sweep program I turned off the arduino IDE and started running the Processing IDE. But for some reason the the arduino code does not get overwritten which it should. I don't understand why its not working, when I did the same thing 1 week ago and the processing IDE was sending the data and moving the servos.
Check this website: http://protolab.pbworks.com/w/page/19403605/ArduinoProcessingLibraryReference
Not sure if this makes a difference, but shouldn't you be using
arduino.servoAttach(int pin)
?So far... COM ports are verified.
Servo works on Arduino as you tried it out using the Arduino monitor
[Next step] Make sure a connection is being established. Maybe use a println in setup? Maybe modify your ino code so it sends other data beside servo data? For example, sending time data every second and then you intercept that package in processing?
Can you reset your arduino before you connect your USB cable to it?
Kf
Whats the difference between arduino.servoAttach(int pin) and arduino.servoWrite(3, int(Servo1.getValue())) ?