Change a board in a firmware - possible? (Arduino Pro Micro to Arduino Micro )

Hello,

I will do a "Mouth Operated Mouse" from Thingiverse (Mouth Operated Mouse by 0_o - Thingiverse) for a friend of me.

Now, the builder of this great project programmed a firmware for "Arduino Pro Micro (5V version)".

Now my problem, i dont find the same Arduino Board, and buyed a:

"Original Arduino Micro with Atmega32u4" (Play-Zone.CH Original Arduino Micro mit Atmega32u4)

Now my question :slight_smile:

Is it possible to change this firmware for the "Micro Pro"(https://www.thingiverse.com/download:1713689) - Board to a version for the "Micro 5V" board :

With the rest i'm finished, i printed the parts and do all de rest, now i cannot upload a firmware and dont know what and how to change, that it works on my board.

I hope you understand what i mean, i'n not a programmer but i want to learn this, its a really cheap project that helps handicaped people a lot to live their life! Would be great if anyone could help me with this project! :slight_smile:

Much thanks and greetz!

raffakn

Most Arduino programs will work on any Arduino board unless they rely on some specific feature.

Post your program.
And please use the code button </>so your code looks like thisand is easy to copy to a text editor

...R

i dont find the same Arduino Board ("Arduino Pro Micro (5V version)")

The Arduino Micro should be a nearly-identical replacement for the "Pro Micro" - they have the same chip, but the newer board breaks out more of the pins, has a reset switch, and etc.

The "pro micro" was never an official Arduino board - you can still buy them from Sparkfun (the original developer) https://www.sparkfun.com/products/12640, and maybe from eBay (but be careful not to get one of the much-more-common "Pro Mini" clones.)

@ Robin2

Yeah, thats what i was thinking too, but i dont know where to start.

What you mean, what should i post? Just the "main-code" from the arduino file?

/*
  Basic example for the T-Rex Mouse project
  based on the 'HID Joystick Mouse Example' by Jim Lindblom (2012)
  by: T. Wirtl
  date: 16/10/2015
  license: MIT License - Feel free to use this code for any purpose.
  No restrictions. Just keep this license if you go on to use this
  code in your future endeavors! Reuse and share.
*/

#include "TimerOne.h"

#define X_AXIS_PIN A0
#define Y_AXIS_PIN A1
#define BUTTON_PIN 2
#define SENSOR_PIN 3

#define TIMER_OVERRUN_USEC 100000  // Timer overrun in usecs (defines the sensitivity of the sensor)
#define AXIS_SENSITIVITY   30      // Higher sensitivity value = slower mouse, should be <= about 500

int vertZero, horzZero;            // Stores the initial value of each axis, usually around 512
int vertValue, horzValue;          // Stores current analog output of each axis


volatile int clickLeft = 0;


// On timer overrun
void timerIrq()
{
  clickLeft = 0; // Let's handle this in the main loop
  Timer1.stop();
}

// On rising edge of the sensor pin
void sensorIrq()
{
  TCNT1 = 1; // Timer restart without triggering the interrupt  
  if (!clickLeft)
  {
    Timer1.start(); // Start the timer if not already started
  }
  clickLeft = 1; // Let's handle this in the main loop
}

void setup()
{
  // Pin config
  pinMode(X_AXIS_PIN, INPUT);      // Set both analog pins as inputs
  pinMode(Y_AXIS_PIN, INPUT);
  pinMode(BUTTON_PIN, INPUT);      // Pin for the connected button
  pinMode(SENSOR_PIN, INPUT);      // Pin for the sensor
  digitalWrite(BUTTON_PIN, HIGH);  // Enable pull-up on button pin (active low)
  
  // Timer initialization
  Timer1.initialize(TIMER_OVERRUN_USEC);
  Timer1.attachInterrupt(timerIrq);
  attachInterrupt(0, sensorIrq, RISING);
  
  // Axis calibration
  delay(1000);                        // short delay to let outputs settle
  vertZero = analogRead(Y_AXIS_PIN);  // get the initial values
  horzZero = analogRead(X_AXIS_PIN);  // Joystick should be in neutral position when reading these

}

void loop()
{
  static int mouseClickFlagRight = 0;
  static int mouseClickFlagLeft = 0;
  
  // Get ADC vals
  vertValue = (analogRead(Y_AXIS_PIN) - vertZero);  // read vertical offset
  horzValue = (analogRead(X_AXIS_PIN) - horzZero);  // read horizontal offset
  
  // Axis movement
  if (vertValue != 0)
  {
    Mouse.move(0, vertValue/AXIS_SENSITIVITY, 0);  // move mouse on y axis
  }
  
  if (horzValue != 0)
  {
    Mouse.move(horzValue/AXIS_SENSITIVITY, 0, 0);  // move mouse on x axis
  } 
  
  // Right mouse button
  if ((digitalRead(BUTTON_PIN) == 0) && (!mouseClickFlagRight))  // if the joystick button is pressed
  {
    mouseClickFlagRight = 1;
    Mouse.press(MOUSE_RIGHT);  // click the left button down
  }
  else if ((digitalRead(BUTTON_PIN))&&(mouseClickFlagRight)) // if the joystick button is not pressed
  {
    mouseClickFlagRight = 0;
    Mouse.release(MOUSE_RIGHT);  // release the left button
  }
  
  // Left mouse button
  if ((clickLeft) && (!mouseClickFlagLeft))  // if the joystick button is pressed
  {
    mouseClickFlagLeft = 1;
    Mouse.press(MOUSE_LEFT);  // click the left button down
  }
  else if ((!clickLeft)&&(mouseClickFlagLeft)) // if the joystick button is not pressed
  {
    mouseClickFlagLeft = 0;
    Mouse.release(MOUSE_LEFT);  // release the left button
  }
  
}

This is the Main-filecode or whats called it? but if i click on the open symbol there are much more files.

The file is in the attachments.

@ westfw

i found these, but i was thinking i would to try to do it with the micro, it cannot be that hard. But after 2 hours of google, for me was the best way to ask here in the forum how to start in adruino for a problem like this. :wink:

greetz

t_rex_mouse.ino (3.23 KB)

Atmega32u4 is the only thing that counts when it comes to firmware.

Fuse settings will allow you to change how the chip behaves with different crystals added

For example the Arduino Leonardo runs at 16 MHz because of the crystal oscillator attached
The 3v Arduino Pro Micro runs at 8 MHz and requires different fuses to be set so you will need to

your board Arduino Pro Micro runs exactly the same with exactly the same crystal so you could use the same fuses settings...

So burning the bootloader for the Arduino Leonardo (Set for 5V and 16MHz default) will work great with the Arduino Pro Micro 5V 16MHz version!

C:\Program Files (x86)\Arduino\hardware\arduino\avr
boards.txt

leonardo.name=Arduino Leonardo
leonardo.vid.0=0x2341
leonardo.pid.0=0x0036
leonardo.vid.1=0x2341
leonardo.pid.1=0x8036
leonardo.vid.2=0x2a03
leonardo.pid.2=0x0036
leonardo.vid.3=0x2a03
leonardo.pid.3=0x8036

leonardo.upload.tool=avrdude
leonardo.upload.protocol=avr109
leonardo.upload.maximum_size=28672
leonardo.upload.maximum_data_size=2560
leonardo.upload.speed=57600
leonardo.upload.disable_flushing=true
leonardo.upload.use_1200bps_touch=true
leonardo.upload.wait_for_upload_port=true

leonardo.bootloader.tool=avrdude
leonardo.bootloader.low_fuses=0xff
leonardo.bootloader.high_fuses=0xd8
leonardo.bootloader.extended_fuses=0xcb
leonardo.bootloader.file=caterina/Caterina-Leonardo.hex
leonardo.bootloader.unlock_bits=0x3F
leonardo.bootloader.lock_bits=0x2F

leonardo.build.mcu=atmega32u4
leonardo.build.f_cpu=16000000L
leonardo.build.vid=0x2a03
leonardo.build.pid=0x8036
leonardo.build.usb_product="Arduino Leonardo"
leonardo.build.board=AVR_LEONARDO
leonardo.build.core=arduino
leonardo.build.variant=leonardo
leonardo.build.extra_flags={build.usb_flags}


##############################################################

micro.name=Arduino Micro
micro.upload.tool=avrdude
micro.upload.protocol=avr109
micro.upload.maximum_size=28672
micro.upload.maximum_data_size=2560
micro.upload.speed=57600
micro.upload.disable_flushing=true
micro.upload.use_1200bps_touch=true
micro.upload.wait_for_upload_port=true

micro.bootloader.tool=avrdude
micro.bootloader.low_fuses=0xff
micro.bootloader.high_fuses=0xd8
micro.bootloader.extended_fuses=0xcb
micro.bootloader.file=caterina/Caterina-Micro.hex
micro.bootloader.unlock_bits=0x3F
micro.bootloader.lock_bits=0x2F

micro.build.mcu=atmega32u4
micro.build.f_cpu=16000000L
micro.build.vid=0x2a03
micro.build.pid=0x8037
micro.build.usb_product="Arduino Micro"
micro.build.board=AVR_MICRO
micro.build.core=arduino
micro.build.variant=micro
micro.build.extra_flags={build.usb_flags}

Even thought the files are different for the boot-loaders comparing the two files at

C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\caterina

The two .hex files are exactly the same size:
Caterina-Leonardo.hex
Caterina-Micro.hex
10.8 KB (11,109 bytes)

You say you cannot upload the program to the Micro board.
You need to post the error messages that you get?
What Arduino board have you selected in the Arduino IDE?
What version of the Arduino IDE are you using?

Have you tried uploading one of the simple example programs from the Arduino IDE?
Was that successful?
This would help us to know whether you have a general problem or whether it is specific to the program you are hoping to use.

...R

If i try to veryfi the firmware with choose "Adruino / Genuino Micro" it gives me this error on "arduino 1.6.9":

Build options changed, rebuilding all
C:\Users\anonym.anonym\Desktop\t_rex_mouse\t_rex_mouse.ino:11:22: fatal error: TimerOne.h: No such file or directory

 #include "TimerOne.h"

                      ^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Micro.

what am i doing wrong?

@ zhomeslice

Should i try to do bootloader? and after that install the firmware? wich board should i chose?

Robin2:
Have you tried uploading one of the simple example programs from the Arduino IDE?
Was that successful?
This would help us to know whether you have a general problem or whether it is specific to the program you are hoping to use.

...R

How do you mean that? Sorry i'm at the beginning?

Yeah!! I'm a step further :slight_smile:
I includet the hid, the mouse and the timerone libary, now it moves! :slight_smile:

but it seems to be as i have to change more things that it works good. The sensor is not working yet, dont know why. And on y axe the mouse goes wrong way, but i try to find a value , i can change for these.

Edit:

How can i change the y axe movement of my mouse upside-down in the mouse.move(0,0,0) function, or do i have to go upper where it's getting the zero-values?

// Axis calibration
  delay(1000);                        // short delay to let outputs settle
  vertZero = analogRead(Y_AXIS_PIN);  // get the initial values
  horzZero = analogRead(X_AXIS_PIN);  // Joystick should be in neutral position when reading these

}

void loop()
{
  static int mouseClickFlagRight = 0;
  static int mouseClickFlagLeft = 0;
  
  // Get ADC vals
  vertValue = (analogRead(Y_AXIS_PIN) - vertZero);  // read vertical offset
  horzValue = (analogRead(X_AXIS_PIN) - horzZero);  // read horizontal offset
  
  // Axis movement
  if (vertValue != 1)
  {
    Mouse.move(0, vertValue/AXIS_SENSITIVITY, 0);  // move mouse on y axis
  }
  
  if (horzValue != 0)
  {
    Mouse.move(horzValue/AXIS_SENSITIVITY, 0, 0);  // move mouse on x axis
  }

Edit 2:

Ok, found set a "-" before vertValue/AXIS_SENSITIVITY and it works:

 if (vertValue != 1)
  {
    Mouse.move(0, -vertValue/AXIS_SENSITIVITY, 0);  // move mouse on y axis
  }

thanks for the help!

So, i've made it. I found out that the sensor only works on 5V but the joystick works also at 3.3V, now the rest was just a little bit of change in the x and y axes and change values of sensitivity.

So all good for now. Very happy, thanks for your help guys!