Hello, I'm currently working on creating a mobile cart and working on it with my phone. First of all, I'll tell you about what I'm doing right now.
- Using the gps module to float latitude and longitude and let the marker move on the map.
- The ability to set a point point point and call it to that point
- Manipulating the motor and water pump manually
I'm working on these three things, but it worked before to float latitude and longitude on gps and make the marker move, but now there is no value and the marker is not moving. There is no error message. There is a change in the combination of Arduino codes, so can you check it? And if you press the Save Points button, an error message occurs and the app turns off.
The picture is the block code I wrote.
And I would appreciate it if you could know that the app inventory's mobile app doesn't work in a non-Wi-Fi environment, so I'm working on it in kodular.
I'm writing here because I don't have enough knowledge about writing that block code and Arduino side. Please.


And there is no problem with the current motor, water pump, and movement, so the code is not attached separately.
*************arduino code*****************
#include <TinyGPS++.h>
void moveForward();
void moveBackward();
void turnLeft();
void turnRight();
void stopMotors();
// ====== serial setting ======
#define GPS_SERIAL Serial3 // GPS
#define BT_SERIAL Serial1 // bluetooth HC-06
// ====== GPS setting ======
TinyGPSPlus gps;
unsigned long lastLocationTime = 0;
unsigned long lastPrintTime = 0;
float prevLat = 0.0;
float prevLon = 0.0;
// ====== waterpump pin ======
const int PUMP_EN = 12;
const int PUMP_IN1 = 8;
const int PUMP_IN2 = 9;
bool pumpon = false;
// ====== wheel motor pin ======
#define FRONT_LEFT_4_IN1 53
#define FRONT_LEFT_4_IN2 52
#define FRONT_LEFT_4_PWM 9
#define FRONT_RIGHT_3_IN1 50
#define FRONT_RIGHT_3_IN2 51
#define FRONT_RIGHT_3_PWM 8
#define REAR_LEFT_2_IN1 38
#define REAR_LEFT_2_IN2 39
#define REAR_LEFT_2_PWM 3
#define REAR_RIGHT_1_IN1 41
#define REAR_RIGHT_1_IN2 40
#define REAR_RIGHT_1_PWM 2
String command = "";
void setup() {
// serial Initialization
Serial.begin(9600);
GPS_SERIAL.begin(9600);
BT_SERIAL.begin(9600);
Serial.println("start");
// waterpump pin Initialization
pinMode(PUMP_EN, OUTPUT);
pinMode(PUMP_IN1, OUTPUT);
pinMode(PUMP_IN2, OUTPUT);
// wheel motor pin Initialization
pinMode(FRONT_LEFT_4_IN1, OUTPUT); pinMode(FRONT_LEFT_4_IN2, OUTPUT);
pinMode(FRONT_RIGHT_3_IN1, OUTPUT); pinMode(FRONT_RIGHT_3_IN2, OUTPUT);
pinMode(REAR_LEFT_2_IN1, OUTPUT); pinMode(REAR_LEFT_2_IN2, OUTPUT);
pinMode(REAR_RIGHT_1_IN1, OUTPUT); pinMode(REAR_RIGHT_1_IN2, OUTPUT);
// PWM pin setting
pinMode(FRONT_LEFT_4_PWM, OUTPUT);
pinMode(FRONT_RIGHT_3_PWM, OUTPUT);
pinMode(REAR_LEFT_2_PWM, OUTPUT);
pinMode(REAR_RIGHT_1_PWM, OUTPUT);
}
void loop() {
char cmd = '0';
if (Serial1.available()) { // Processing data received from the Bluetooth module
command = Serial1.readStringUntil('\n');
command.trim();
// GPS reception and transmission
while (GPS_SERIAL.available() > 0) {
char c = GPS_SERIAL.read();
gps.encode(c);
if (gps.location.isUpdated()) {
float lat = gps.location.lat();
float lon = gps.location.lng();
// Send via Bluetooth
BT_SERIAL.print(lat, 6);
BT_SERIAL.print(",");
BT_SERIAL.print(lon, 6);
BT_SERIAL.println();
Serial.print("lat: ");
Serial.print(lat, 6);
Serial.print(" / lon: ");
Serial.println(lon, 6);
// calculation of the amount of change
float diffLat = abs(lat - prevLat);
float diffLon = abs(lon - prevLon);
Serial.print("the change in latitude: ");
Serial.print(diffLat, 6);
Serial.print(" / the change in longitude: ");
Serial.println(diffLon, 6);
// Save previous location
prevLat = lat;
prevLon = lon;
lastLocationTime = millis();
}
}
// GPS Receive failure warning
if (millis() - lastLocationTime > 3000 && millis() - lastPrintTime > 3000) {
Serial.println("no location data");
BT_SERIAL.println("no data");
lastPrintTime = millis();
}
// GPS Check module abnormalities
if (millis() > 10000 && gps.charsProcessed() < 10) {
Serial.println("GPS error");
BT_SERIAL.println("GPS error");
while (true); // stop
}
// Bluetooth Command Receipt
if (BT_SERIAL.available()) {
char cmd = BT_SERIAL.read();
Serial.print("an order received: ");
Serial.println(cmd);
}
// control waterpump
if (cmd == '1') {
pumpon = true;
digitalWrite(PUMP_IN1, HIGH);
digitalWrite(PUMP_IN2, LOW);
}
else if (cmd == '0') {
pumpon = false;
digitalWrite(PUMP_IN1, LOW);
digitalWrite(PUMP_IN2, LOW);
}
// waterpump speed
if (pumpon) {
if (cmd == 'H') analogWrite(PUMP_EN, 255); // 최대
if (cmd == 'M') analogWrite(PUMP_EN, 128); // 중간
if (cmd == 'L') analogWrite(PUMP_EN, 64); // 저속
}
// move control
if (command == "GO") {
moveForward();
Serial.println("GO");
} else if (command == "BACK") {
moveBackward();
Serial.println("BACK");
}
else if (command == "STOP") {
stopMotors();
Serial.println("STOP");
} else if (command == "LEFT") {
turnLeft();
Serial.println("LEFT");
} else if (command == "RIGHT") {
turnRight();
Serial.println("RIGHT");
}
// a move command(Call Point)
switch (cmd) {
case 'U': moveForward(); break;
case 'D': moveBackward(); break;
case 'L': turnLeft(); break;
case 'R': turnRight(); break;
case 'S': stopMotors(); break;
}
}
}
// ========== motor control ==========
void moveForward() {
// front
digitalWrite(FRONT_LEFT_4_IN1, HIGH); digitalWrite(FRONT_LEFT_4_IN2, LOW);
digitalWrite(FRONT_RIGHT_3_IN1, LOW); digitalWrite(FRONT_RIGHT_3_IN2, HIGH);
analogWrite(FRONT_RIGHT_3_PWM, 60);
analogWrite(FRONT_LEFT_4_PWM, 60);
// rear
digitalWrite(REAR_LEFT_2_IN1, HIGH); digitalWrite(REAR_LEFT_2_IN2, LOW);
digitalWrite(REAR_RIGHT_1_IN1, LOW); digitalWrite(REAR_RIGHT_1_IN2, HIGH);
analogWrite(REAR_LEFT_2_PWM, 60);
analogWrite(REAR_RIGHT_1_PWM, 60);
}
void moveBackward() {
// front
digitalWrite(FRONT_LEFT_4_IN1, LOW); digitalWrite(FRONT_LEFT_4_IN2, HIGH);
digitalWrite(FRONT_RIGHT_3_IN1, HIGH); digitalWrite(FRONT_RIGHT_3_IN2, LOW);
analogWrite(FRONT_RIGHT_3_PWM, 60);
analogWrite(FRONT_LEFT_4_PWM, 60);
// rear
digitalWrite(REAR_LEFT_2_IN1, LOW); digitalWrite(REAR_LEFT_2_IN2, HIGH);
digitalWrite(REAR_RIGHT_1_IN1, HIGH); digitalWrite(REAR_RIGHT_1_IN2, LOW);
analogWrite(REAR_LEFT_2_PWM, 60);
analogWrite(REAR_RIGHT_1_PWM, 60);
}
void turnLeft() {
// front
digitalWrite(FRONT_LEFT_4_IN1, HIGH); digitalWrite(FRONT_LEFT_4_IN2, LOW);
digitalWrite(FRONT_RIGHT_3_IN1, LOW); digitalWrite(FRONT_RIGHT_3_IN2, HIGH);
analogWrite(FRONT_RIGHT_3_PWM, 90);
analogWrite(FRONT_LEFT_4_PWM, 15);
// rear
digitalWrite(REAR_LEFT_2_IN1, HIGH); digitalWrite(REAR_LEFT_2_IN2, LOW);
digitalWrite(REAR_RIGHT_1_IN1, LOW); digitalWrite(REAR_RIGHT_1_IN2, HIGH);
analogWrite(REAR_LEFT_2_PWM, 15);
analogWrite(REAR_RIGHT_1_PWM, 90);
}
void turnRight() {
// front
digitalWrite(FRONT_LEFT_4_IN1, HIGH); digitalWrite(FRONT_LEFT_4_IN2, LOW);
digitalWrite(FRONT_RIGHT_3_IN1, LOW); digitalWrite(FRONT_RIGHT_3_IN2, HIGH);
analogWrite(FRONT_RIGHT_3_PWM, 15);
analogWrite(FRONT_LEFT_4_PWM, 90);
// rear
digitalWrite(REAR_LEFT_2_IN1, HIGH); digitalWrite(REAR_LEFT_2_IN2, LOW);
digitalWrite(REAR_RIGHT_1_IN1, LOW); digitalWrite(REAR_RIGHT_1_IN2, HIGH);
analogWrite(REAR_LEFT_2_PWM, 15);
analogWrite(REAR_RIGHT_1_PWM, 90);
}
void stopMotors() {
analogWrite(FRONT_LEFT_4_PWM, 0);
analogWrite(FRONT_RIGHT_3_PWM, 0);
analogWrite(REAR_LEFT_2_PWM, 0);
analogWrite(REAR_RIGHT_1_PWM, 0);
digitalWrite(FRONT_LEFT_4_IN1, LOW); digitalWrite(FRONT_LEFT_4_IN2, LOW);
digitalWrite(FRONT_RIGHT_3_IN1, LOW); digitalWrite(FRONT_RIGHT_3_IN2, LOW);
digitalWrite(REAR_LEFT_2_IN1, LOW); digitalWrite(REAR_LEFT_2_IN2, LOW);
digitalWrite(REAR_RIGHT_1_IN1, LOW); digitalWrite(REAR_RIGHT_1_IN2, LOW);
}
I'm really sorry, but I'm sending you the entire Arduino code.