We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I am using the Arduino Library for Processing (http://playground.arduino.cc/Interfacing/Processing#.UwpkhoXW9Pa) and the arduino is hooked up to a motor controller for a chassis I have(https://www.sparkfun.com/products/11593). I have narrowed the fact that my motors will not turn down to the fact that my code is wrong. Could someone suggest a way this code could work?
import org.firmata.*;
import processing.serial.*;
import cc.arduino.*;
Serial port;
Arduino arduino;
int driveMotorPWM1 = 11; //1st drive motor PWM for driver board
int driveMotorI1 = 12; //I = Current
int driveMotorDir1 = 13; //Dir = Direction
int driveMotorPWM2 = 10;
int driveMotorI2 = 9;
int driveMotorDir2 = 8;
int conveyorPWM = 5; //Conveyor controlled by motor driver board as well, so has same inputs
int conveyorI = 6;
int conveyorDir = 7;
int servo = 4;
int speed = 0;
void goForward() {
arduino.digitalWrite(driveMotorI1 & driveMotorDir1, Arduino.HIGH);
arduino.analogWrite(driveMotorPWM1, speed);
arduino.digitalWrite(driveMotorI2 & driveMotorDir2, Arduino.HIGH);
arduino.analogWrite(driveMotorPWM2, speed);
}
void goBack() {
arduino.digitalWrite(driveMotorI1, Arduino.HIGH);
arduino.digitalWrite(driveMotorDir1, Arduino.LOW);
arduino.analogWrite(driveMotorPWM1, 255);
arduino.digitalWrite(driveMotorI2, Arduino.HIGH);
arduino.digitalWrite(driveMotorDir2, Arduino.LOW);
arduino.analogWrite(driveMotorPWM2, 255);
}
void goRight()
{
arduino.digitalWrite(driveMotorI1 & driveMotorDir1, Arduino.HIGH);
arduino.analogWrite(driveMotorPWM1, 255);
arduino.digitalWrite(driveMotorI2, Arduino.HIGH);
arduino.digitalWrite(driveMotorDir2, Arduino.LOW);
arduino.analogWrite(driveMotorPWM2, 255);
}
void goLeft()
{
arduino.digitalWrite(driveMotorI1, Arduino.HIGH);
arduino.digitalWrite(driveMotorDir1, Arduino.LOW);
arduino.analogWrite(driveMotorPWM1, 255);
arduino.digitalWrite(driveMotorI2 & driveMotorDir2, Arduino.HIGH);
arduino.analogWrite(driveMotorPWM2, 255);
}
void setup() {
size(400, 400);
println("Available serial ports:");
println(Serial.list());
arduino = new Arduino(this, "COM3", 9600);
arduino.pinMode(driveMotorPWM1, Arduino.OUTPUT);
arduino.pinMode(driveMotorI1, Arduino.OUTPUT);
arduino.pinMode(driveMotorDir1, Arduino.OUTPUT);
arduino.pinMode(driveMotorPWM2, Arduino.OUTPUT);
arduino.pinMode(driveMotorI2, Arduino.OUTPUT);
arduino.pinMode(driveMotorDir2, Arduino.OUTPUT);
arduino.pinMode(conveyorPWM, Arduino.OUTPUT);
arduino.pinMode(conveyorI, Arduino.OUTPUT);
arduino.pinMode(conveyorDir, Arduino.OUTPUT);
arduino.pinMode(servo, Arduino.SERVO);
}
void draw() {
arduino.digitalWrite(driveMotorI1, Arduino.HIGH);
arduino.digitalWrite(driveMotorDir1, Arduino.HIGH);
arduino.digitalWrite(driveMotorPWM1, Arduino.HIGH);
}
Thanks, DebianAddict