buenas otra vez,le regale un coche de esos que tienen el keystudio con un guante(esp32+mpu6050) para controlarlo y en el coche esp32+l298n, el codigo que me mandan es este :
Receptor
#include <esp_now.h>
#include <WiFi.h>
// Motor pin definitions
#define IN1 13
#define IN2 12
#define IN3 14
#define IN4 27
#define ENA 26
#define ENB 25
#define enableRightMotor ENB
#define rightMotorPin1 IN3
#define rightMotorPin2 IN4
#define enableLeftMotor ENA
#define leftMotorPin1 IN1
#define leftMotorPin2 IN2
#define MAX_MOTOR_SPEED 200
const int PWMFreq = 1000;
const int PWMResolution = 8;
const int rightMotorPWMSpeedChannel = 4;
const int leftMotorPWMSpeedChannel = 5;
#define SIGNAL_TIMEOUT 1000
unsigned long lastRecvTime = 0;
struct PacketData {
byte xAxisValue;
byte yAxisValue;
byte switchPressed;
};
PacketData receiverData;
bool throttleAndSteeringMode = false;
// Callback when ESP-NOW data is received
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len) {
if (len == 0) return;
memcpy(&receiverData, incomingData, sizeof(receiverData));
String inputData = "Values: " + String(receiverData.xAxisValue) + " " + String(receiverData.yAxisValue) + " " + String(receiverData.switchPressed);
Serial.println(inputData);
if (receiverData.switchPressed == true) {
throttleAndSteeringMode = !throttleAndSteeringMode;
}
if (throttleAndSteeringMode) {
throttleAndSteeringMovements();
} else {
simpleMovements();
}
lastRecvTime = millis();
}
void simpleMovements() {
if (receiverData.yAxisValue <= 75) {
rotateMotor(MAX_MOTOR_SPEED, MAX_MOTOR_SPEED);
} else if (receiverData.yAxisValue >= 175) {
rotateMotor(-MAX_MOTOR_SPEED, -MAX_MOTOR_SPEED);
} else if (receiverData.xAxisValue >= 175) {
rotateMotor(-MAX_MOTOR_SPEED, MAX_MOTOR_SPEED);
}
// Add more movement conditions as needed
}
pero me lanza el arduino ide este error :
C:\\Users\\casa\\AppData\\Local\\Temp.arduinoIDE-unsaved2025929-5236-17jnvno.33hd\\sketch_oct29b\\sketch_oct29b.ino: In function 'void OnDataRecv(const uint8_t\*, const uint8_t\*, int)':
C:\\Users\\casa\\AppData\\Local\\Temp.arduinoIDE-unsaved2025929-5236-17jnvno.33hd\\sketch_oct29b\\sketch_oct29b.ino:54:5: error: 'throttleAndSteeringMovements' was not declared in this scope; did you mean 'throttleAndSteeringMode'?
54 | throttleAndSteeringMovements();
| ^\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~
| throttleAndSteeringMode
C:\\Users\\casa\\AppData\\Local\\Temp.arduinoIDE-unsaved2025929-5236-17jnvno.33hd\\sketch_oct29b\\sketch_oct29b.ino: In function 'void simpleMovements()':
C:\\Users\\casa\\AppData\\Local\\Temp.arduinoIDE-unsaved2025929-5236-17jnvno.33hd\\sketch_oct29b\\sketch_oct29b.ino:64:5: error: 'rotateMotor' was not declared in this scope
64 | rotateMotor(MAX_MOTOR_SPEED, MAX_MOTOR_SPEED);
| ^\~\~\~\~\~\~\~\~\~\~
C:\\Users\\casa\\AppData\\Local\\Temp.arduinoIDE-unsaved2025929-5236-17jnvno.33hd\\sketch_oct29b\\sketch_oct29b.ino:66:5: error: 'rotateMotor' was not declared in this scope
66 | rotateMotor(-MAX_MOTOR_SPEED, -MAX_MOTOR_SPEED);
| ^\~\~\~\~\~\~\~\~\~\~
C:\\Users\\casa\\AppData\\Local\\Temp.arduinoIDE-unsaved2025929-5236-17jnvno.33hd\\sketch_oct29b\\sketch_oct29b.ino:68:5: error: 'rotateMotor' was not declared in this scope
68 | rotateMotor(-MAX_MOTOR_SPEED, MAX_MOTOR_SPEED);
| ^\~\~\~\~\~\~\~\~\~\~
exit status 1
Compilation error: 'throttleAndSteeringMovements' was not declared in this scope; did you mean 'throttleAndSteeringMode'?