We are trying to run the robot at full speed when all IR sensors are on white line
(values IR sensors>500) and at low speed for any other condition.
Our programming code is given below :
//
#include<ArduinoRobot.h>
int IRarray;
void setup()
{
Robot.begin();
}
void loop()
{
Robot.updateIR();
if(Robot.IRarray[0]>500 && Robot.IRarray[1]>500 && Robot.IRarray[2]>500 && Robot.IRarray[3]>500 && Robot.IRarray[4]>500)
Robot.motorsWrite(255,255);
else
Robot.motorsWrite(50,50);
}
//
It is executing only the first update of the sensors,after that if the IR values change it continues to follow the instruction of only the first update. what is the problem? Is the loop even running?
Have you tested the motorsWrite() method using a simple test sketch with no other logic, to confirm that it actually controls the motors correctly?
system
March 11, 2016, 8:53am
4
Is the loop even running?
Why don't you add some debug prints to tell you what is happening?
I think I already suggested this on another thread on the same subject
Link to the library, please? Or was that also in the other thread?
we have already tried debug prints but it is not working, the values keep updating but the motor executes the first update only.
amir-10_:
yes we did that.
Please post the motor test sketch that you used.
we have given our program above..we are using a arduino robot
amir-10_:
we have given our program above..we are using a arduino robot
No, not that one. The motor only test sketch that you mentioned! I asked about it in reply #1 .
system
March 11, 2016, 9:46am
10
amir-10_:
we have already tried debug prints but it is not working,
the values keep updating but the motor executes the first update only.
It's either "working" and the updates are taking place, or it isn't "working".
Or you're not showing us the code that you used to test this, or the output.
Yes, I think I like that last explanation best.
#include <ArduinoRobot.h>
#include <Wire.h>
#include <SPI.h>
void setup() {
// initialize the robot
Robot.begin();
}
void loop() {
Robot.motorsWrite(255, 255); // move forward
delay(2000);
Robot.motorsStop(); // fast stop
delay(1000);
Robot.motorsWrite(-255, -255); // backward
delay(1000);
Robot.motorsWrite(0, 0); // slow stop
delay(1000);
Robot.motorsWrite(-255, 255); // turn left
delay(2000);
Robot.motorsStop(); // fast stop
delay(1000);
Robot.motorsWrite(255, -255); // turn right
delay(2000);
Robot.motorsStop(); // fast stop
delay(1000);
}
this is simple program and its working just fine, but the program with array one is causing problem
system
March 11, 2016, 10:06am
12
I'm still not seeing any debug output.
Or code tags.
Your test sketch doesn't test any speed but full speed. Since the problem sketch uses a reduced speed, this is not a thorough test.
#include <ArduinoRobot.h>
#include <Wire.h>
#include <SPI.h>
void setup() {
// initialize the robot
Robot.begin();
}
void loop() {
Robot.motorsWrite(255, 255);
delay(2000);
Robot.motorsStop();
delay(1000);
Robot.motorsWrite(255, 0);
delay(1000);
Robot.motorsWrite(0, 0);
delay(1000);
Robot.motorsWrite(0, 255);
delay(2000);
Robot.motorsStop();
delay(1000);
Robot.motorsWrite(100, 50);
delay(2000);
Robot.motorsStop();
delay(1000);
}
Great. What did you observe?
By the way, you've repeatedly been asked to use code tags.
The robot is executing all the commands perfectly. These simple programs are easily and perfectly executed.
In case of white line following program the robot is performing the first update only, it is only executing the commands in the loop for once, then it is going straight without taking any turns. If you have tried any such operations, can you post the sketch here? It will be very helpful.
system
March 14, 2016, 10:28am
17
Even more useful would be to see your code (in code tags, of course) along with your observations and debug output.
amir-10_:
The robot is executing all the commands perfectly. These simple programs are easily and perfectly executed.
So, just to be sure, you see the motors running at reduced speed with the test sketch?