Hi,
a few days ago i got my arduino uno. i'm new to programming, electronics and stuff. : but i can learn fast.
i'm trying to build a RC LEGO-car at the moment with GUI,sensors....
i'm using processing and firmata to everything and it works fine. but a few hours ago i bought a servo and it's not working.
when i use StandartFirmata the motor controller works, but the servo is not doing wgat it should.
but when i use ServoFirmata the servo works perfect, but the motor controller is not working.
i use arduino IDE 0022, processing 1.2.1
does anyone know a solution for my problem?
btw: sry for my bad english skills
here's my processing code:
import net.java.games.input.*;
import processing.serial.*;
import cc.arduino.*;
import procontroll.*;
import java.io.*;
ControllIO controll;
ControllDevice device;
ControllStick stick;
ControllStick stick1;
ControllButton button1;
ControllButton button;
int LED = 7;
int speed;
int licht = 4; //LDR
int motorpin1 = 9; //when motorpin1 HIGH motorpin2 LOW = forward....
int motorpin2 = 7;
int motorpwm = 11;
int standby = 8;
int geschw;
int richt;
int lichtval;
int steer;
int leucht;
int m;
int servoPin = 10;
int richtung;
String s = "Speed:";
String l = "Licht:";
String r = "Richtung:";
PFont myFont;
Arduino arduino;
void setup()
{
size(400,400);
arduino = new Arduino(this, Arduino.list()[1]);
arduino.pinMode(LED, arduino.OUTPUT);
arduino.pinMode(licht, arduino.INPUT);
arduino.pinMode(motorpin1, arduino.OUTPUT);
arduino.pinMode(motorpin2, arduino.OUTPUT);
arduino.pinMode(motorpwm, arduino.OUTPUT);
arduino.digitalWrite(standby, arduino.HIGH);
arduino.pinMode(servoPin, arduino.OUTPUT);
myFont = createFont("Arial", 20);
textFont(myFont);
controll = ControllIO.getInstance(this);
device = controll.getDevice("Logitech Cordless RumblePad 2");
device.printSticks();
device.setTolerance(0.1f);
device.printButtons();
ControllSlider sliderX = device.getSlider("Z-Achse");
ControllSlider sliderY = device.getSlider("Z-Rotation");
ControllSlider sliderX1 = device.getSlider("X-Achse");
ControllSlider sliderY1 = device.getSlider("Y-Achse");
stick = new ControllStick(sliderX,sliderY);
stick1 = new ControllStick(sliderX1,sliderY1);
button = device.getButton("Taste 0");
button1 = device.getButton("Taste 2");
}
void draw()
{
background(150);
lichtval = arduino.analogRead(licht);
text(s, 30,30);
fill(0);
geschw = int(-speed/2.55);
text(geschw, 120, 30);
text(l, 30, 60);
leucht= int(-lichtval/4/2.55); //my "GUI"
text(leucht+100, 120, 60);
text(r, 30, 90);
richt = int(steer);
text(richt, 120, 90);
if(button.pressed()){
arduino.digitalWrite(LED, Arduino.HIGH);
}
else
{arduino.digitalWrite(LED, Arduino.LOW);
}
speed = int(stick.getY()*255); // get right value for motor controller
steer = int(stick1.getX()*90+90); // get right value for servo
arduino.analogWrite(servoPin, 0);
println(steer); //print different values for debuging
if(speed > 0){
arduino.digitalWrite(motorpin1, arduino.LOW);
arduino.digitalWrite(motorpin2, arduino.HIGH); //forward
arduino.digitalWrite(standby, arduino.HIGH);
arduino.analogWrite(motorpwm, speed);
}
if(speed < 0){
arduino.digitalWrite(motorpin1, arduino.HIGH);
arduino.digitalWrite(motorpin2, arduino.LOW); //back
arduino.digitalWrite(standby, arduino.HIGH);
arduino.analogWrite(motorpwm, speed*-1);
}
if(speed == 0){
arduino.digitalWrite(standby, arduino.LOW); //motor controller standby
}
}