Arcade Drive Code?

Hello. I was just wondering if anyone knew the raw code for the arcade drive module in easyC. I am creating a robot that needs arcade drive, but I can’t use easyC to program it, so I am kind of stuck :confused:

Does this help?
https://vexforum.com/wiki/index.php/Term_-_Arcade_Style_Drive

No :confused: I have tried that, and I can’t get it to work.

That is quite odd… What exactly are the symptoms you are experiencing?

EDIT:
And can you post your code (even if it is the Arduino C code?)

Here is the whole code. The values on the axis go from 0-180.

// http://www.commandfusion.com/docs/scripting/sensors.html

var y=0; // Roll; Forwards and Backwards. 0 is middle, 1 is forwards, -1 is back
var x=0; // Pitch; Left and Right
var in_min=-1;
var in_max=1;
var out_min=0;
var out_max=180;

var leftmotor=90;
var rightmotor=90;

CF.userMain = function() {

CF.startMonitoring(CF.AttitudeSensor, { historySize:50, captureInterval:20, reportInterval:100 }, gyro);

};

function gyro(sensorType, dataasdf){
	y=dataasdf[0].roll;
	x=dataasdf[0].pitch;
	
	if(y>1){
		y=1;
	}else if(y<-1){
		y=-1;
	}
	if(x>1){
		x=1;
	}else if(x<-1){
		x=-1;
	}
	
	y=(y - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
	y=Math.round(y);
	x=(x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
	x=Math.round(x);
	
	//leftmotor=(y/2)-(x/2);
	//rightmotor=(y/2)+(x/2);
	
	if (x < 90) //  if x negative, turning left; otherwise, turning right
    {
        leftmotor = (y * (100 + (2 * x))/100); // left motor reduced for right turn
        rightmotor = y;                           // right motor not changed
    }
    else
    {
        rightmotor = (y * (100 - (2 * x))/100); // right motor reduced for left turn
        leftmotor = y;                            // left motor not changed
    }
	
	CF.setJoin("a1", y*364);
	CF.setJoin("a2", x*364);
	
	CF.log("L: " + leftmotor);
	CF.log("R: " + rightmotor);
}

Let me explain a little more. I wrote this code for guiCreater made by CommandFusion, which lets you make guis for your iOS or Android device, so what I am trying to do is read the gyro and send it to the Arduino via wifi udp. Reading the gyro and mapping the values to 0-180 works fine. I can send the values fine. I just need to figure out how to split up each axis to run both motors.

I made it work, so here is the code I modified:

if (x < 90) //  if x negative, turning left; otherwise, turning right
    {
        //leftmotor = (y * (100 + (2 * x))/100); // left motor reduced for right turn
        rightmotor = y;                           // right motor not changed
		leftmotor=(y-90)+x;
    }
    else
    {
        //rightmotor = (y * (100 - (2 * x))/100); // right motor reduced for left turn
        leftmotor = y;                            // left motor not changed
		rightmotor=(y+90)-x;
    }
	
	leftmotor=Math.abs(leftmotor);
	rightmotor=Math.abs(rightmotor);
	leftstring="M1:" + leftmotor + ";";
	rightstring="M2:" + rightmotor + ";";

Are you using the Arduino IDE to program this?

For the code you see above, I used CommandFusion’s guiDesigner, which is based off of JavaScript. It’s basically C.

Have you ever looked into using programs such as “processing” and apps like “touchOSC?” Theyre both free and work pretty well.

I have used processing, but I haven’t heard of touchOSC before. CommandFusion guiDesigner and iViewer are both free, and are actually really neat once you figure it out. Basically, you can create a program on your computer, and upload it to, say your iPod, then it will run on your iPod. Currently, my program has three user input methods: gyro, sliders, and buttons. They send wirelessly over wifi to the Arduino to control the robot. I’ll have to see what touchOSC is.

Here is an image of my gui:

http://aksoapy29.netai.net/controls.png

Hi Soapy,

Aaron from CommandFusion here. We are always looking to show of interesting uses of our software.
Are you interested in helping us out with a case study? I will do most of the work - would just need some images and maybe a video?

Shoot me an email at aaron (at) commandfusion.com if you are interested.

Just want to say:
This is a case-in-point of how doing cool stuff with robotics can get you noticed by businesses. :slight_smile:

//Andrew