hi im fake joe ! i am trying to send f to my arduino and it fights me ! posting the arduino and the processing clip ! small clip of much larger program ! the arduino runs fine if i use the serial monitor ! i just type in f and the servos run ! when i try to run it from the processing program nothing much happens !
processing clip
// WALKFORWARD WITHOUT ANY TURN
portwritenable3 = 1;
cam.stop();
delay(60);
myPort.stop();
delay(60);
Serial myPort;
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 115200);
for (serialcounter2 = 0; serialcounter2 <= 6; serialcounter2++)
{
if (portwritenable3 == 1)
{
myPort.write("f");
delay(30);
myPort.write("f");
delay(30);
myPort.write("f");
delay(30);
myPort.write("f");
delay(30);
myPort.write("f");
delay(30);
myPort.write("f");
delay(30);
// myPort.write(13);
// myPort.clear();
// Close the port
delay(30);
cam.start();
println("HAVE A BIG BIG HUGGY DAY3 !!!!!!!!!");
THE ARDUINO PROGRAM
#include <Servo.h>
int potPin0 = 0;
int potPin1 = 1;
#include <Wire.h> //I2C Arduino Library
#define Magnetometer_mX0 0x03
#define Magnetometer_mX1 0x04
#define Magnetometer_mZ0 0x05
#define Magnetometer_mZ1 0x06
#define Magnetometer_mY0 0x07
#define Magnetometer_mY1 0x08
int mX0, mX1, mX_out;
int mY0, mY1, mY_out;
int mZ0, mZ1, mZ_out;
float Xm,Ym,Zm;
#define Magnetometer 0x1E //I2C 7bit address of HMC5883
#define BMP085_ADDRESS 0x77 // I2C address of BMP085
const unsigned char OSS = 0; // Oversampling Setting
// Calibration values
int ac1;
int ac2;
int ac3;
unsigned int ac4;
unsigned int ac5;
unsigned int ac6;
int b1;
int b2;
int mb;
int mc;
int md;
// b5 is calculated in bmp085GetTemperature(...), this variable is also used in bmp085GetPressure(...)
// so ...Temperature(...) must be called before ...Pressure(...).
long b5;
short temperature;
long pressure;
//--- Gyro Register Addresses
#define Gyro_gX0 0x28
#define Gyro_gX1 0x29
#define Gyro_gY0 0x2A
#define Gyro_gY1 0x2B
#define Gyro_gZ0 0x2C
#define Gyro_gZ1 0x2D
int Gyro = 0x69; //Device address in which is also included the 8th bit for selecting the mode, read in this case.
int gX0, gX1, gX_out;
int gY0, gY1, gY_out;
int gZ0, gZ1, gZ_out;
float Xg,Yg,Zg;
float angleX,angleY,angleZ,angleXc,angleYc,angleZc;
unsigned long start, finished, elapsed;
float dt=0.015;
//--- Accelerometer Register Addresses
#define Power_Register 0x2D
#define X_Axis_Register_DATAX0 0x32 // Hexadecima address for the DATAX0 internal register.
#define X_Axis_Register_DATAX1 0x33 // Hexadecima address for the DATAX1 internal register.
#define Y_Axis_Register_DATAY0 0x34
#define Y_Axis_Register_DATAY1 0x35
#define Z_Axis_Register_DATAZ0 0x36
#define Z_Axis_Register_DATAZ1 0x37
int ADXAddress = 0x53; //Device address in which is also included the 8th bit for selecting the mode, read in this case.
int X0,X1,X_out;
int Y0,Y1,Y_out;
int Z1,Z0,Z_out;
float Xa,Ya,Za;
// GPS
#include "TinyGPS++.h"
#include "SoftwareSerial.h"
SoftwareSerial serial_connection(10, 11); //RX=pin 10, TX=pin 11
TinyGPSPlus gps;//This is the GPS object that will pretty much do all the grunt work with the NMEA data
int coom1 = 1;
int coom2 = 1;
Servo myservo0;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
Servo myservo6;
Servo myservo7;
Servo myservo8;
Servo myservo9;
Servo myservo10;
Servo myservo11;
// Servo servo1; Servo servo2;
Servo servo1; // create servo object to control a servo
Servo servo2; // create servo object to control a servo
Servo servo3; // create servo object to control a servo
Servo servo4; // create servo object to control a servo
Servo servo5; // create servo object to control a servo
Servo servo6; // create servo object to control a servo
Servo servo7; // create servo object to control a servo
Servo servo8; // create servo object to control a servo
Servo servo9; // create servo object to control a servo
Servo servo10; // create servo object to control a servo
Servo servo11; // create servo object to control a servo
Servo servo12; // create servo object to control a servo
Servo servo13; // create servo object to control a servo
Servo servo14; // create servo object to control a servo
Servo servo15;
Servo servo16;
Servo servo17;
Servo servo18;
Servo servo19;
Servo servo20;
Servo servo21;
Servo servo22;
Servo servo23;
Servo servo24;
Servo servo25;
Servo servo26;
Servo servo27;
Servo servo28;
Servo servo29;
Servo servo30;
Servo servo31;
Servo servo32;
Servo myservo33;
Servo myservo34;
Servo myservo35;
Servo myservo36;
Servo servo37;
Servo servo38;
Servo servo39;
Servo servo40;
int ch = 0;
int blue = 0;
int triggeronthrottle = 0;
int fenable = 0;
int triggeronthrottlef = 0;
int triggeronthrottlee = 0;
int destinatione = 0;
int destinationf = 0;
int destinationg = 0;
int destinationh = 0;
int eenable = 0;
int eenablevalgreater = 0;
int eenablevalgreater1 = 0;
int eenablevalless = 0;
int fenablevalfgreater = 0;
int fenablevalfless = 0;
int vale = 0;
int valf = 0;
int valg = 0;
int valh = 0;
int ecountenable = 0;
int destine = 0;
int destinf = 0;
int stand = 1;
int leenleft = 140;
int kneerightbend = 100;
int legrightforward = 50;
int legleftbackward = 100;
int leenright = 70;
int leenleftdrill2 = 70;
int leenleftdrill5 = 70;
int servo1speeddrill2 = 90;
int kneeleftbenddrill1 = 100;
int kneeleftbend = 100;
int kneerightbenddrill0 = 100;
int legleftforward = 50;
int legleftforwarddrill4 = 50;
int legrightbackwarddrill3 = 90;
int legleftbackwarddrill4 = 90;
int legrightbackward = 100;
int legrightforwarddrill3 = 100;
int leenrightdrill2 = 90;
int leenrightdrill5 = 90;
int servo5speedoffdrill0 = 90;
int servo5speeddrill0 = 90;
int servo1speedoffdrill2 = 90;
int servo3speedoffdrill5 = 90;
int servo3speeddrill5 = 90;
int servo11speedoffdrill1 = 90;
int servo11speeddrill1 = 90;
int servo9speedoffdrill4 = 90;
int servo9speeddrill4 = 90;
int servo7speedoffdrill3 = 90;
int servo7speeddrill3 = 90;
int turnleft = 1;
int turnright = 1;
int triggeronthrottleg = 0;
int triggeronthrottleh = 0;
void setup() {
myservo0.attach(2);
myservo1.attach(3);
myservo2.attach(4);
myservo3.attach(5);
myservo4.attach(6);
myservo5.attach(7);
myservo36.attach(36);
// delay(30);
myservo34.attach(34);
// delay(30);
//Initialize Serial and I2C communications
pinMode(potPin0, INPUT);
pinMode(potPin1, INPUT);
pinMode(potPin0, INPUT);
Serial.begin(115200);
}
void loop() {
int v = 0;
// if ( Serial.available()) {
// char ch = Serial.read();
delay(20);
char ch = Serial.read();
delay(30);
// Serial.println(ch);
v = Serial.read();
// delay(0);
blue = Serial.read();
delay(10);
// Serial.println(v);
// v = v * 10 + ch;
// ch = 'f';
if (ch == 'f')
{
// valf = map(analogRead(potPin1), 0, 1023, 0, 500);
delay(30);
// valf = valf * 1.3;
destinationf = v;
triggeronthrottlef = blue;
// Serial.println("fffffffffffffffff");
destinf = valf - destinationf;
// if (destinf > 1 || destinf < - 1)
// {
// if (valf >= destinationf)
// {
fenablevalfgreater = 1;
myservo34.attach(34);
delay(30);
myservo34.write(140); // 100 TRIGGER OFF triger new drill off
delay(20); // THE HIGHER THE NUMBER THE MORE TO OFF DIRECTION
myservo34.detach();
delay(300); // THE HIGHER THE NUMBER THE MORE TO OFF DIRECTION
myservo33.attach(33);
delay(30);
myservo33.write(140); // 120 NEW DRILL DIRECTION FORWARD THE BIGGER THE NUMBER THE MORE FORWARD
delay(30);
myservo33.detach();
delay(30); // THE HIGHER THE NUMBER THE MORE TO OFF DIRECTION
myservo34.attach(34);
delay(30);
myservo34.write(95); // 95 triggeronthrottlef NEW DRILL TRIGER ON SMALLER NUMBER IS HIGHER SPEED
delay(30);
myservo36.attach(36);
delay(30);
myservo36.write(43); // no cha 42 GOOD triggeronthrottlee OLD DRILL TRIGGER 0N triger
// myservo34.detach();
delay(30); // THE HIGHER THE NUMBER THE MORE TO OFF DIRECTION
/*
servo32.attach(33);
delay(30);
servo32.write(v);
delay(200);
servo32.detach();
delay(200);
*/
v = 0;
// ch = 'f';
// }
// if (valf <= destinationf)
// {
fenablevalfless = 1;
myservo34.attach(34);
delay(30);
myservo34.write(140); // 100 TRIGGER OFF triger new drill off
delay(20); // THE HIGHER THE NUMBER THE MORE TO OFF DIRECTION
myservo34.detach();
delay(30); // THE HIGHER THE NUMBER THE MORE TO OFF DIRECTION
myservo33.attach(33);
delay(30);
myservo33.write(60); // 70 NEW DRILL reverse
delay(30);
myservo33.detach();
delay(30); // THE HIGHER THE NUMBER THE MORE TO OFF DIRECTION
myservo34.attach(34);
delay(30);
myservo34.write(100); //95 triggeronthrottlef NEW DRILL TRIGER ON SMALLER NUMBER IS HIGHER SPEED
delay(30);
myservo36.attach(36);
delay(30);
myservo36.write(44); // 40 45 32 30 50 35 triggeronthrottlee OLD DRILL TRIGGER On triger
delay(20);
myservo36.attach(36);
delay(30);
myservo36.write(63); // 43 TRIGGER On triggeronthrottlee triger OLD drill off
delay(50);
// myservo34.detach();
// delay(300); // THE HIGHER THE NUMBER THE MORE TO OFF DIRECTION
// Serial.println("FFFFFFFFFFFFFFFFFFF");
/*
servo32.attach(33);
delay(30);
servo32.write(v);
delay(200);
servo32.detach();
delay(200);
*/
v = 0;
ch = 'f';
// }
// }
}
// } // if ( Serial.available
}