USB Host Shield GPIO Arduino Library

USB Host Shield GPIO, is an Arduino library, that allows you to easily access the GPIO pins of the Max 3421 IC present in the USB Host Shield.

Features

This library allows both read and write operations on the GPIO pins of the Max 3421 IC. Each pin can be read or written separately like the digitalWrite or digitalRead.

Also note that only digital write and read are supported, since the IC doesn’t support PWM.

Setup

Stack the USB Host shield on top of Arduino. After that connect the GIn or GOut pins of the shield to your circuit as needed.

Usage

To use the library, you have to include the MaxGPIO.h header file. After including the header file, create an instance of the MaxGPIO class. You can call the write() or read() method on that object that you have created. These functions are similar to the digitalWrite() and digitalRead() functions which is present in the core.

I have included an example sketch inside the examples folder that explains how you can access the library.

Video

I have also uploaded a video, which shows how you can use this library to access the GPIO pins. In the video, I have added 8 LED’s to the 8 GOut pins and I control each of them separately.

Download

You can download the library from its github page. The examples are there inside the /examples folder. After downloading place the USB_Host_Shield_GPIO folder inside your Arduino’s /library folder.

Dependency

This library requires the USB Host Shield library, without which this can’t work.

License

The library and the examples are released under released under BeerWare license.

I would, however, consider it a great courtesy if you could email me and tell me about your project and how this code was used, just for my own continued personal gratification.

Stay updated

If you want to be informed when new version of this library is released, then subscribe to this blog’s RSS feed or follow @hardwarefun in twitter.

History

  • 2012-10-29 – v0.1 – Initial version

9 thoughts on “USB Host Shield GPIO Arduino Library

  1. crond

    well done.
    In gitgub page, there is one Make file and c file.
    Where exactly is the library?
    I am new to Arduino . I want to move totally into Atmel from PIC.

    If you make a blog post on “How to create a library”, that will be very helpful.

    Nandri,

    PS: so, you lied that you hack on sundays in mail list. You are hacking on weekdays too , isn’t it? πŸ™‚

    Reply
    1. Sudar Post author

      The USB_Host_Shield_GPIO.{h.cpp} files in the root of the githuh repo is the actual library. The files in the example folder shows you how you can call the library.

      To install the library, you have to copy all the files in the repo to a folder called USB_Host_Shield_GPIO and place it inside the library folder of your Arduino installation. Once you do that, you will be able to open the examples from file->examples in the IDE.

      Will write a detailed post about libraries soon.

      I didn’t lie in the mailing list. I just said I hack on weekends. That doesn’t mean that I don’t hack on weekdays as well πŸ˜‰ In general I hack and play around with stuff, whenever I get a chance or free time πŸ™‚

      Reply
  2. FMalh3iro

    Hi, i’ve this error:

    arduino-1.0.3librariesUSBHostShieldGPIO/USB_Host_Shield_GPIO.h:32: error: ‘rIOPINS1’ was not declared in this scope

    How i resolve this?

    Reply
        1. Sudar Post author

          There was an include missing in the example file. I have updated and pushed the changes to github.

          Kindly take the latest version and you should not face this issue.

          Reply
          1. Sudar Post author

            Nice to know that this solved your issue.

            Do let me know if you manage to do something interesting with this library.

  3. Me

    Hi seem to be having some trouble with the max.read function. If I read all 8 pins which are conected to buttons, half read low and half high, always.

    Is there an error in the library?

    The max.write is fine.

    Reply

Leave a Reply to Sudar Cancel reply

Your email address will not be published. Required fields are marked *