2 Arduinos react differently to the same setup

I have a school project and used a arduino Uno for prototyping. It worked fine on the arduino uno, but when I decided to change it to a arduino Nano 33 IoT it didn't
I connected all the same pins, but the motor now doesn't work, however the RGB's still work.
I have set it up in a way that pressing the button will cause the motor to go on, and pressing it again will turn it off. There are also some RGB's, but these are not connected to the motor in anyway.
Is there a solution or is it a problem with the board?

The code is below but only a small bottom part is important for my question
(I marked it with This part is important)

const int button = 9;
const int button1= 8;
const int button2= 7;
const int blue = 12;
const int red = 11;
const int green = 10;
int counter = 0;
int status = false;
int motor = 6;
int status2 = true;

void setup() {
pinMode(button, INPUT_PULLUP);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(motor, OUTPUT);
Serial.begin (9600);
}

void loop() {

int buttonState;
buttonState = digitalRead(button);

if (buttonState == LOW) {
counter++;
delay(100);
}

else if (counter == 0) {
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}

else if (counter == 1) {
digitalWrite(red, HIGH);
digitalWrite(green, HIGH);
digitalWrite(blue, LOW);
}

else if (counter == 2) {
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(blue, LOW);
}

else if (counter == 3) {
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
}

else if (counter == 4) {
digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
}

else if (counter == 5) {
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
}

else {
counter = 0;
}

// This part is important

do {
int status1;
status1 = digitalRead(button2);

if (status1 == 0){
status2 = !status2;
delay (100);}

if (status2 == 0){
digitalWrite (motor, HIGH);

}
else { digitalWrite (motor, LOW);
}

// until here

if (digitalRead(button1) == 0){
status=!status;
delay (100);
}
if (status ==0){
digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}

Serial.print(status2);
Serial.print("/");
Serial.print(digitalRead(button2));
Serial.print("/");
Serial.println(digitalRead(motor));
delay (100);

} while (status == 0);

}

Sorry in advance for my probably bad code and bad schematic, I'm still learning and any advise would help :slight_smile:

Thank you in advance

arduino schematic doesnt work.pdf (1.52 MB)

You're wiring a motor to an I/O pin?

What do you mean by wiring a motor to an I/O pin, I followed several tutorials untill something worked on the arduino uno, i coppied it wire by wire to the arduino nano, but then it didn't work.

  • Always provide as much detail as possible to your issue it may be important.
  • If applicable provide your SKETCH inside CODE TAGS ( </> ) or a CREATE share link.
  • If applicable provide a schematic even if hand drawn.
  • How to insert a picture into your post
  • If applicable provide a proper LINK to the hardware / sensors etc. you are using.

Bob.

You moved your project from a 5V Uno to a 3.3V board with a different processor.

Have you read the important information about the differences between the original Nano and the Nano 33 IoT at Arduino Nano 33 IoT — Arduino Official Store (look in Tech Specs)?

How exactly is your motor wired?

Steve

I already used the 3.3 v output on the arduino uno, im using a corelesa dc motor, which doesnt use a lot of power.
Is there something I'm missing? I'm sorry if I cant give the information you need to know to help me.

TheMemberFormerlyKnownAsAWOL:
You're wiring a motor to an I/O pin?

Dafrion:
What do you mean by wiring a motor to an I/O pin,

Dafrion:
I already used the 3.3 v output on the arduino uno, im using a corelesa dc motor, which doesnt use a lot of power

It seems from the code you posted that this motor has one end on pin 6 is that right? And the other on the 3V3 supply?

int motor = 6;
pinMode(motor, OUTPUT);
digitalWrite (motor, HIGH);
digitalWrite (motor, LOW);

That means (on the Uno) a digitalWrite(6, LOW) will put 3V3 and 0V across the motor one way (let's say "clockwise"), and a digitalWrite(6, HIGH) will put 3V3 and 5V across the motor the other way (effectively 1V7 "anticlockwise").

Disregarding the fact that it's not really off with the high, you have motor current running through a digital pin.

Dafrion:
I already used the 3.3 v output on the arduino uno, im using a corelesa dc motor, which doesnt use a lot of power

You need to put a number on that..

Exactly what "coreless motor" are you trying to use and again how is it wired (i.e. where are both wires connected!). How much is "not a lot of power"? I have coreless motors that run at currents that would kill a digital pin instantly.

Steve

I think I am using a coreless micro dc motor, I dont know the exact model because I took it out of a toy car. And I am sorry, what do you mean by where are both wires connected? I think I am missing something obvious.

Dafrion:
what do you mean by where are both wires connected? I think I am missing something obvious.

A motor has 2 wires, one needs positive and one to ground. We're trying to understand where you connected them: what pins?

Where did you plug the red wire? Where did you plug the blue/black wire?

edit... I don't mean, btw, that those are your motors. Just random pic from the 'net to show that motors have 2 wires :wink:

Dafrion:
I think I am using a coreless micro dc motor, I dont know the exact model because I took it out of a toy car. And I am sorry, what do you mean by where are both wires connected? I think I am missing something obvious.

Those motors use a lot of power, 2A is typical (coreless slotless high speed DC motors designed for micro-drones easily pull that kind of current from a 3.7V LiPo).

No motor, even one that small, can ever be powered directly from a logic signal without issues and probably damage. Motors always need motor drivers.