Does the UNO r4 wifi accept different code to a mega2560?

Total noobie here so please be kind.
I am trying to build a bluetooth remote controlled car.
I have a mega 2560 board and a uno r4 wifi board,
part of the code I am using, not written by me, fails with the r4 board but is ok with the 2560.

i.e.:

#include <AFMotor.h>

//initial motors pin
AF_DCMotor motor1(1, MOTOR12_1KHZ); 
AF_DCMotor motor2(2, MOTOR12_1KHZ); 
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);

i get back:-

C:\Users\moone\Downloads\BluetoothCar 3\BluetoothCar\BluetoothCar.ino:12:22: error: 'MOTOR12_1KHZ' was not declared in this scope
 AF_DCMotor motor1(1, MOTOR12_1KHZ);
                      ^~~~~~~~~~~~
C:\Users\moone\Downloads\BluetoothCar 3\BluetoothCar\BluetoothCar.ino:12:22: note: suggested alternative: 'MOTOR2_A'
 AF_DCMotor motor1(1, MOTOR12_1KHZ);
                      ^~~~~~~~~~~~
                      MOTOR2_A
C:\Users\moone\Downloads\BluetoothCar 3\BluetoothCar\BluetoothCar.ino:13:22: error: 'MOTOR12_1KHZ' was not declared in this scope
 AF_DCMotor motor2(2, MOTOR12_1KHZ);
                      ^~~~~~~~~~~~
C:\Users\moone\Downloads\BluetoothCar 3\BluetoothCar\BluetoothCar.ino:13:22: note: suggested alternative: 'MOTOR2_A'
 AF_DCMotor motor2(2, MOTOR12_1KHZ);

The 2560 board has no problem with this.
At present I have no idea what this means.
Can someone explain please.

cheers

Paul

Welcome to the forum.
Please read How To Get The Best From This Forum and post your entire sketch using code tags, as the article explains. It is difficult to determine what may be causing an issue without seeing the code. Thanks.

The library you are using has been archived and does not support the Uno R4. Try using Adafruit_Motor_Shield_V2_Library

Is that not for a different version of the shield?

1 Like

Yes, the V1 version is no longer in production and is not supported. The V1 library is archived and not maintained, so the OP either must modify it or move on to the new board.
The old library only supports AVR and PIC32MX.

1 Like

Hi, the V2 didn't work either
Thanks anyway

Paul

Imagine a wagon full of hay in a field that needs to be transported to the barn. You have several options to pull it—a horse, a donkey, or a tractor and each is powerful enough to get the job done. Think of the Arduino as the force behind the wagon; each Arduino has its own advantages and disadvantages, much like how horses come in various breeds and colors.

Similarly, the compiler takes the code you write and converts it into the language that the processor understands. It does this through several steps and needs to know the specific target processor, since different processors (like horses and tractors) require different approaches.

Not quite sure what you are saying here as I don't know much about C++ and Arduino but thanks anyway

Your original question was about the using AFMotor library with Uno R4 board.
The answer that your selected library is not compatible with R4.

Do you have another question?

Hi,
Thanks that clears that up.
Is there an equivalent I could use or does that make everything in the code I am using wrong?

Paul

Hi @espxm01

welcome to the arduino forum

This error-message says:

Your code has a line that wants to use the "name" MOTOR12_1KHZ
But the libraries that were used for the Uno R4 have no definition for this "name"

As an analogy:

Your Arduino Mega 2560 uses screws with heads like this

You can use these screws with a tool like this

The Arduino Uno R4 uses screws like this

and these screws simply can't be rotated with this tool

You need a tool like this

For the software there is NO simple replacement like this


which could be used as an equivalent.

And if you want further help how your problem can be solved with the smallest effort.
You will have to describe your complete project very detailed to make the oroum-readers understand what you hardware you have.

The solution with the smallest effort will highly depend on these particular hardware that you are using.
So list up

  • size of your car
  • weight of your car
  • how many motors?
  • what exact type of motor? DC?, BLDC?, steppermotor? continious rotating servo?
  • final purpose of your car (just make it drive around for itself for fun or something more
  • what kind of remote-control? 433 Mhz?, 866 Mhz?, nRF24?, Bluetooth (which module?), classic RC?, WiFi?

I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.

Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.

Hi, thanks for the reply.
I rebuilt the car and after replacing the code and the HC-05 I finally got the car to move from my phone.
The forwards and backwards buttons are reversed so I'm trying to understand the code to figure this out.
I will read the information which will hopefully help me get better.

Paul

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.