How to add mobiflight library to arduino ide?

following is my code

#include <Joystick.h>
#include <Mux.h>
#include "MobiFlight.h"  // Include MobiFlight core functionality

#define JOYSTICK_COUNT 2

Joystick_ Joystick[JOYSTICK_COUNT] = {
  Joystick_(0x03, JOYSTICK_TYPE_JOYSTICK, 29, 0, false, false, false, false, false, false, false, false, false, false, false),
  Joystick_(0x04, JOYSTICK_TYPE_JOYSTICK, 25, 0, false, false, false, false, false, false, false, false, false, false, false)
};

Mux mux1(Pin(9, INPUT_PULLUP, PinType::Digital), Pinset(13, 12, 11, 10));
Mux mux2(Pin(3, INPUT_PULLUP, PinType::Digital), Pinset(7, 6, 5, 4));
Mux mux3(Pin(A4, INPUT_PULLUP, PinType::Digital), Pinset(A0, A1, A2, A3));

void setup() {
  MobiFlight.begin();  // Initialize MobiFlight
  for (int index = 0; index < JOYSTICK_COUNT; index++) {
    Joystick[index].begin();
  }
}

void loop() {
  MobiFlight.run();  // Run MobiFlight tasks
  
  // Joystick Processing
  Joystick[0].setButton(1, !mux1.read(11));
  Joystick[0].setButton(0, !mux1.read(10));
  Joystick[0].setButton(3, !mux1.read(8));
  Joystick[0].setButton(2, !mux1.read(9));
  Joystick[0].setButton(4, !mux1.read(13));
  Joystick[0].setButton(6, !mux1.read(14));
  Joystick[0].setButton(5, !mux1.read(15));
  Joystick[0].setButton(7, !mux1.read(12));
  
  toggle3PosA(0, 11, 20);
  toggle3PosA(0, 13, 23);
  toggle3PosB(1, 1, 0);
  toggle3PosB(1, 3, 3);
}

void toggle3PosA(int joy, int pin, int key) {
  if (!mux2.read(pin) == 0 && !mux2.read(pin + 1) == 0) {
    Joystick[joy].setButton(key, 0);
    Joystick[joy].setButton(key + 1, 1);
    Joystick[joy].setButton(key + 2, 0);
  }
}

void toggle3PosB(int joy, int pin, int key) {
  if (!mux3.read(pin) == 0 && !mux3.read(pin + 1) == 0) {
    Joystick[joy].setButton(key, 0);
    Joystick[joy].setButton(key + 1, 1);
    Joystick[joy].setButton(key + 2, 0);
  }
}


following is the error i get when building

MobiFlight.h: No such file or directory

Welcome to Arduino Forum

Please post your code in code tags.

Go through this post to understand how to post in code tags and other essential information

Welcome to the forum

As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming category of the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Which version of the IDE are you using ?

i am really sorry, i have added the code tags

my ide version 1.8.19

This suggests that the particular library is not correctly installed.
If you have not installed the library. Try searching in the library manager of Arduino IDE.
If your version doesn't have the library manager or you cannot find it in the library manager download the zip file from github and move the file to the Arduino libraries folder.

i have tried the following but with no success. there is no mobiflight library available for my ide and ever after manually downloading the zip file there is no file inside the zip that the ide recognizes as a proper library file

Can you post a link to the zip? I guess it's one of those (MobiFlight · GitHub) but I could not quickly figure out which one exactly.

Once you have downloaded a ZIP'ed library, you can use Sketch → Include Library → Add .ZIP Library to install it.

the same link you mentioned above.
I tried installing all zip files but none of them are correct libraries for ide, infact I cant seem to find the mobiflight library anywhere

All those repositories don't seem to be repositories for the Arduino IDE (as you found out). I have no idea how it all is supposed to work so can't really help further.

YEAH, I SEEM TO BE STUCK IN A LOOP
help from anybody is highly appreciated, if not ill just have to look for some other workaround

You might get more information on the Mobiflight forum MobiFlight

The only Arduino compatible library on the link above is

But this repository doesn't contains a MobiFlight.h.

Could you describe your project in general? What do you want to achieve? Where did the code from the first message come from? If you found it on the Internet - provide a link

mobiflight.h is in GitHub - MobiFlight/MobiFlight-FirmwareSource: Firmware source for MobiFlight. However, it has support for PlatformIO, maybe not for Ardunio IDE?

im trying to build a joystick that is recognised as both a module and a joystick in mobiflight. the code is written by me with a little help of gpt
i cant seem to find the correct library of mobiflight for ide so i am unable to flash the code that contains #include "Mobiflight.h"

Ask ChatGPT where to find it

1 Like

I think you will need to move from the Arduino IDE to PlatformIO to use the mobiflight source.

Why not connect the analog outputs of your DIY joystick also to the mobiflight module and then map those values to your control axis in your Mobiflight Connector?
I agree with @bobcousins that you may get better help from the mobiflight forum.

yea sure I will try doing that, and yes also sure I will try asking in the mobiflight community once
thanks for the help though

Hi @nk123451 . Did you find an answer to this?

In any case, I am looking to do the same as you, but instead of MobiFlight I am trying out the Spad.Next route. It doesn't require any libraries, you just send text commands via the serial connection.

Just a quick update. SPAD.neXt's serial interface was very easy to work with. As mentioned earlier, it doesn't require any external libraries, just the "text" commands being sent over the serial interface.

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