Hi, I want to draw the movement path of my robot. I mean I want to draw a path that my robot move in that direction. can any one help me?
Do you want to get the path the robot is following, or do you want to set a path for the robot to follow ?
I want to set a pass for robot to follow.
How do you want to draw the path ?
By swiping on the screen
Do you mean swipe to the right, car turns right and moves forward in that direction, for example ?
Just keep what you want to do close to your chest, let me keep asking questions until we know what it is you want to do...(sarcasm)
I want to draw a curve and the robot follows it.
Here is an example of what you might do. I have simulated the movement of the car in the smaller canvas. You would need a "map" of the area the car operates in, so that the coordinates recorded on the large canvas can be translated to positions for the car to move to. I do not have such a car so do not know how you might program this part. This may be enough to get you going...
drawRouteForCar.aia (4.9 KB)
Others may have better suggestions...
Tank you very much. How can I open the attached file?
In appinventor 2
How to design the blocks for this code?
#include <SoftwareSerial.h>
#include <Servo.h>
#include "HCPCA9685.h"
SoftwareSerial BT(13,12); //RX , TX pins
char state=0;
/* I2C slave address for the device/module. For the HCMODU0097 the default I2C address
is 0x40 */
#define I2CAdd_1 0x40
#define I2CAdd_2 0x41
int pos1=0;
int pos2=100;
int pos3=200;
int pos5=150;
const float pos4=80.0/pos5;
/* Create an instance of the library */
HCPCA9685 HCPCA9685_1(I2CAdd_1);
HCPCA9685 HCPCA9685_2(I2CAdd_2);
void setup() {
// Initialise both modules
HCPCA9685_1.Init(SERVO_MODE);
HCPCA9685_2.Init(SERVO_MODE);
// Wake both devices up
HCPCA9685_1.Sleep(false);
HCPCA9685_2.Sleep(false);
unsigned int Pos;
Serial.begin(9600);
BT.begin(9600);
}
/* Move Forward */
void move_forward() {
HCPCA9685_1.Servo(2, pos1);
HCPCA9685_1.Servo(5, pos1);
}
/* Move Backward */
void move_backward() {
HCPCA9685_1.Servo(2, pos2);
HCPCA9685_1.Servo(5, pos2);
}
/* Move Right */
void turn_right() {
HCPCA9685_1.Servo(0, pos1);
HCPCA9685_1.Servo(3, pos1);
}
/* Move Left */
void turn_left() {
HCPCA9685_1.Servo(0, pos2);
HCPCA9685_1 .Servo(3, pos2);
}
/* Stop Move */
void move_stop() {
HCPCA9685_1.Servo(0, pos2);
}
void loop() {
if (BT.available() >0) {
state = BT.read();
Serial.print(state);
if(state == 'F'){
move_forward();
}
else if(state == 'B'){
move_backward();
}
else if(state == 'R'){
turn_right();
}
else if(state == 'L'){
turn_left();
}
// else if (state == "S") {
// move_stop();
// }
}
}
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.