Computers, Development Boards & Shields
Educational & Robotics Kits
Electronic Sensors
Motors & Controllers
Communication & Display
Electronic Components
Soldering & Lab Tools

0
help with robot remote control

 

how do you send robot control info wireless from one uno to another I have spent a couple of weeks trying and got no where yet.

here is my sketch. it uses 2 sliders instead of joy stick. versalino uno  is trans BOE uno for now rec.

int Y;
int X;
int fspeedR;
int bspeedR;
int fspeedL;
int bspeedL;
const int in1 = 2;
const int in2 = 4;
const int ena = 3;
const int in3 = 7;
const int in4 = 8;
const int enb = 9;
void setup()
{
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(ena, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(enb, OUTPUT);

}
void loop()
{

int X = analogRead(A1);
int Y = analogRead(A0);

if (Y < 500)
{
fspeedR = (map(Y, 501, 0, 70, 250));
forwardR(fspeedR);
}

if (Y > 540)
{
bspeedR = (map(Y, 541, 1023, 70, 250));
backwardR(bspeedR);
}
if (Y >= 500 && Y <= 540)
{
stopR();
}

if (X < 500)
{
fspeedL = (map(X, 501, 0, 70, 250));
forwardL(fspeedL);
}

if (X > 540)
{
bspeedL = (map(X, 541, 1023, 70, 250));
backwardL(bspeedL);
}
if (X >= 500 && X <= 540)
{
stopL();
}

}
void stopL()
{
{
analogWrite(ena, 0);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
}
void stopR()
{

{
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
analogWrite(enb, 0);
}
}
void forwardR(int fspeedR)

{
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(ena, fspeedR);
}

void forwardL(int fspeedL)
{
{
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
analogWrite(enb, fspeedL);
}
}
void backwardR(int bspeedR)
{

digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(ena, bspeedR);
}

void backwardL(int bspeedL)
{

digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
analogWrite(enb, bspeedL);
}

11 Answers

0

If  I understand your question, you are trying to send signals from one microcontroller to another. If this is correct, I recently did this with an Arduino UNO and an ADK. The UNO was sampling three ultrasonic sensors. The forward sensor sends a high if the distance is greater than 22 cm, else it sets a low if it is not. The two sensors on either side will detect if the robot is getting close to a wall or obstacle on the side. If the distance is less than 15 cm (6 inches) it will send a high, else it is low. The UNO data pins are set for output. The ADK pins default to input, but you can set them to Input_Pullup which will assure an internal pullup resistor. However, from what I have read this will invert the signal. A high from the UNO will read a low on the ADK. Below are the variables I used for the ADK front sensor.

datainFval = digitalRead(datainF);

I did find this worked if I set datainFval to int and zero initially. The datainF was a define of the pin initially:

#define datainF 41

A conditional statement tests to see if the value for datainFval is a 1.

void loop()
{

delay(1000); // Give UNO time to check distance
datainFval = digitalRead(datainF);
Serial.println(“In main loop function”);
Serial.println(datainFval);

// If the distance is greater than 22 cm go forward
if (datainFval == 1)
{
forwardMotion();
}else
{
findOpen();
}

}

I hope this helps. But like I said, I did this with wires rather than wireless.

0

I would first double check your com link to the Versalino as suggested by etbryant, and then try a simplified version of what you have in your code for debugging (like if one slider is all the way up move the bot forward). Once you have that much working it should be easier to debug the rest of your code one functional block at a time.

If you are still having trouble after those steps let me know and we can go into a more detailed debug.

0

after more research and changing my code around I feel I over my head for now. I played around with the Motor Master code some and think that is easer with one big obstacle how to get it to work with a joystick trans. over xbee to robot.

0

I played around with Josephdattilo joystick code and got it to work with my motor controller I believe the end of the code is to trans the info I need a starting place to rec the info to 2nd  arduino haven’t found any by search the internet. I based every thing for a 2nd versalino so I can attach the motor master to reduce the foot print and code that is available .

thanks

harry

0

i’v trying to send my data over serial but couldn’t find much on how here is what I’ve done so far is there any hope

 

#include “MotorMaster.h”

MotorMaster myMotorMaster = MotorMaster();

void setup()
{
myMotorMaster.begin(BUSA);
Serial.begin(9600);

}

void loop()
{
while(Serial.available() == 0);

int R = Serial.read();
int L = Serial.read();
myMotorMaster.drive(COILA, R);
myMotorMaster.drive(COILB, L);

}

0

So are you trying to directly translate a single byte into the speed of each motor? If so that may work, but you would have to type numbers in based on their ASCII value instead of typing numbers.

Try the program above while hardwired and let me know how it works out.

 

0

it doesn’t wk only 1 number is rec. I need or want that is the rec. format Rxxxx & Lxxxx I have been trying this code it rec the data correctly but it’s all in word called “indata” here is what I have and working on a divider to have my format I need

#include “MotorMaster.h”

MotorMaster myMotorMaster = MotorMaster();
String inData;
int R;
int L;

void setup()
{
Serial.begin(9600);

myMotorMaster.begin(BUSA); //change this and your project will run on a different bus
}

void loop()
{

while (Serial.available() > 0)
{
char recieved = Serial.read();
inData += recieved;

// Process message when new line character is recieved
if (recieved == ‘\n’)
{
Serial.print(“Arduino Received: “);
Serial.print(inData);

// You can put some if and else here to process the message juste like that:

if(inData == “+++\n”){ // DON’T forget to add “\n” at the end of the string.
Serial.println(“OK. Press h for help.”);
}
inData = “”; // Clear recieved buffer
}
}
}

0

So if you want to get multiple characters the way that code is working should do the trick, but you can also use the char* instead of string. You may have noticed that inData is a string type object.

You may have noticed that the way that I pulled multiple bytes was to actually read them into my packet object serially (full code and guide for packets at http://www.josephdattilo.com/passing-data-packets-serial-port-changing-packet-size/)

boolean listenforcommand()
{
if(Serial.available() >=7) //this line was >= 6 we changed it to >= 7
{
if(Serial.read()==’|’ && Serial.read()==’|’)
{
myPacket.received=true;
myPacket.target=Serial.read();
myPacket.msg1=Serial.read();
myPacket.msg2=Serial.read();
myPacket.msg3=Serial.read();
myPacket.msg4=Serial.read();//<−added
//We added the line above to read in the extra message byte into msg4.
}
else myPacket.received=false;
} else myPacket.received=false;
return myPacket.received;
}

Doing things this way puts my data where I need it as it’s pulled, but if you have variable length packets you would want to use a different method (similar to the string method you included).

If you just want to pull simple packets like you described you could change the code above as follows.
char target, msg1, msg2, msg3, msg4;

if(Serial.available() >=7)
{
if(Serial.read()==’|’ && Serial.read()==’|’)
{
target=Serial.read();//this is where L or R would get stored
msg1=Serial.read();//the sign or a 0 would be here
msg2=Serial.read();//the most significant digit
msg3=Serial.read();//the 2nd most significant digit
msg4=Serial.read();//the least significant
}

after that you can do whatever operation you need to on the serial data itself, and you don’t have to use a data structure to store it that way. Let me know if that helps at all, or if you came up with your own solution.

0

Greetings from Los angeles! I’m bored to death at work so I decided to browse your blog on my iphone during lunch break. I really like the info you present here and can’t wait to take a look when I get home. I’m surprised at how quick your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyways, great site!|
dortmund trikot 2014 http://crisi.de/dortmund-trikot-2014/

0
0

Hi, I think your website might be having browser compatibility issues. When I look at your website in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, very good blog!
maillot PSG 2014 http://www.encodia.fr/nouveau-maillot-psg-2014/

0
0

Hi, I think your website might be having browser compatibility issues. When I look at your website in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, very good blog!
nouveau maillot bayern munich 2014 http://www.park-usa.com/skins/maillot-bayern-munich-2014.html

0

Your Answer

No comments yet.

Leave a Reply