Strange behavior of Arduino Micro

Hi,

i recently bought a new Arduino Micro to lessen the dimension of my little project. I developed the Code an the circuit on an Arduino UNO and it worked well. So I wanted to transfer all to the Micro but it didnt work right. So I tested to only run a DC-Motor with a H-Bridge. But the Motor does what it likes.
Its definitely right programmed and connected, it works on my UNO.

Thanks for help.

PS.:I'm sorry for my english :wink:

you might post the code so we can have a look?

int motor_a=6;
int motor_b=5;
int motor_speed=3;

void setup()
{
  pinMode(motor_a, OUTPUT);
  pinMode(motor_b, OUTPUT);
}

void loop()
{
  digitalWrite(motor_a, HIGH);
  digitalWrite(motor_b, LOW);
  for(int i=0;i<256;i+=5)
  {
    analogWrite(motor_speed, i);
    delay(20);
  }
  for(int i=256;i>0;i-=5)
  {
    analogWrite(motor_speed, i);
    delay(20);
  }
  
  digitalWrite(motor_a, LOW);
  digitalWrite(motor_b, HIGH);
  for(int i=0;i<256;i+=5)
  {
    analogWrite(motor_speed, i);
    delay(20);
  }
  for(int i=256;i>0;i-=5)
  {
    analogWrite(motor_speed, i);
    delay(20);
  }
}

Post a picture of the wiring.

Wiring

Ah....

You are powering your board off a pp3 9V battery, I am not sure if it can power everything on the board, or more specifically the motor.

How did you power it with the Uno?

The same way. I also tried 6 AA batteries, but same result.

Is the H bridge being powered from the Arduino 5V pin or directly from the batter?

I used this diagram.

image.jpg

I found out, it remebers the program after uploading it until the next seperation of the batteries.