Hello, new to the forun, I have the DFRobotShop Rover kit coming and was wondering if any one had a basic program for it?
thanks in advance
UncleMike
So my robot tank is coming tomorrow and I started to write some programs for it. I was wondering if I could have some help with some code? My plan is to have object avoidance with a ping sensor. I am still new to robotics and I was wondering if any could help? It doesn’t work…
[code]#define fp 4 //pin the ping sensor is connected to
int ping;
int ping1;
int ping2;
int leftspeed = 255; //255 is maximum speed
int rightspeed = 255;
int E1 = 6; //M1 Speed Control
int E2 = 5; //M2 Speed Control
int M1 = 8; //M1 Direction Control
int M2 = 7; //M2 Direction Control
void setup()
{
}
void loop()
{
int leftspeed = 255; //255 is maximum speed
int rightspeed = 255;
if(ping() > 70)
{
(leftspeed,rightspeed); //Turn right
long duration;
pinMode(fP, OUTPUT);
digitalWrite(fP, LOW);
delayMicroseconds(2);
digitalWrite(fP, HIGH);
delayMicroseconds(15);
digitalWrite(fP, LOW);
delayMicroseconds(20);
pinMode(fP, INPUT);
duration = pulseIn(fP, HIGH);
return duration / 29.0 / 2.0;
(fp = ping1) //I want the value of fp now takes on the value of ping1
}
if (ping1 > ping2)
{
(leftspeed,rightspeed); //turn right
}
if (ping2 > ping1)
{
(leftspeed,rightspeed); //turn left
int ping() //Get CM to obstacle in front of the sensor
{
long duration;
pinMode(fP, OUTPUT);
digitalWrite(fP, LOW);
delayMicroseconds(2);
digitalWrite(fP, HIGH);
delayMicroseconds(15);
digitalWrite(fP, LOW);
delayMicroseconds(20);
pinMode(fP, INPUT);
duration = pulseIn(fP, HIGH);
}[/code]
Dear Cbenson,
I already took a look at the manual, I was wondering if I could use the example code of when the tank turns left for example:
left (leftspeed,rightspeed);
break;
Would this work?
Thanks for the response, but I have another question. I am working on my program and I don’t know what pins the motors and sensors are connected to?
any help appreciated
-Mark
and the l.e.d’s ?
thank you so much for all the help
Hi,
I just received a DFRobotShop Rover kit (with XBee kit) : where I could find the source code of the pre-installed software ?
Thanks in advance
Bubu
Thanks Coleman,
The code that comes with the rover is not only a back/forth test (very usefull to check motors), it also test the temperature and light sensors and use the serial line to display the values. This code is much more powerfull than the code examples in the User Guide (except the ascii remote control).
I would like to have the original (Arduino) source code in order to be able to reinstall the program later : this is my wished tutorial process for children that begin robotics and programming
Tanks in advance
Bubu
Thanks for your advise.
I will do 2 separate programs (I will purchase the V2.0 as soon as available).
I am also looking forward for the “pre-loaded” code if you find it (thanks again)
Best regards
Bubu
Hi UncleMike,
Welcome to the RobotShop Forum. The sample program can be found in the DFRobotShop Rover user guide starting on page 15/24. You can use this code as is, then modify it (and improve it) as you wish.
Sincerely,
Hi Markl,
Welcome to the RobotShop Forum. There is actually sample code available in the DFRobotShop Rover Manual which you can use to test the DFRobotShop Rover following the procedure in the guide or the DFRobotShop Rover Setup Video. You can also see the DFRobotShop Rover assembly guide on YouTube. Once you have tried this, feel free to modify / rewrite / optimize it as you wish.
Sincerely,
The sample code uses subroutines; “left” is a subroutine which requires two variables, leftspeed and rightspeed). In order to use this subroutine, you need to define the variables leftspeed and rightspeed, and also setup the subroutine (as used in the sample program). Alternatively, you can avoid using subroutines and include everything in void loop(). We don’t do much troubleshooting with specific code because even small nuances can cause a program to fail. It takes some time to learn and fortunately with Arduino, there are tons of examples and an active user community. Hope this answers your question. To test your code, build it up section by section, testing and saving each.
Sincerely,
Hi,
The dual motor controller is connected to:
pin 5: M2 speed control
pin 6: M1 speed control
pin 7: M2 direction
pin 8: M1 direction
The temperature and light sensors are connected to analog pins 0 and 1.
You can remove the jumpers if you want to connect other analog devices.
Sincerely,
The LEDs are not controllable - they are turned on/off using the jumper located at the rear right of the board. You can always connect a digital pin to one side and GND to the other to make all 6 LEDs controllable.
Sincerely,
The code that comes with the rover is just a simple back/forth test. The real code is in the DFRobotShop Rover User Guide.
We can try to get the "pre-loaded"code (we will include it here if we can find it), though it was never intended to do anything - just test to see that a program can be uploaded to the board; you can’t use it to control anything. If you are teaching robotics, we suggest using a program to test the sensors (not have the robot move back and forth constantly) and then a separate one for the motion. Note that the V2.0 will no longer include the temperature and light sensors.