Skip to content

I/O Expander 1 pins (8 LEDs) set as outputs, low (LEDs on). I/O Expander 2 pins (SW1-3, 5 joystick inputs) as digital inputs. Button/joystick turns LED off. Curiosity Nano SW resets LEDs on.

License

microchip-pic-avr-examples/avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf

Repository files navigation

Microchip Technologies Inc.

AVR128DB48 I2C_Host Example Component for CNano Explorer: I/O Expander 2 LEDs and BUTTONs (Polled, Printf)

The I2C Host IO Expander 2 - LEDs and Buttons Example, of the MCC Melody I2C Example Component (for the Curiosity Nano Explorer), is used here in the Polled implementation with the Printf visualization.

alt text

On the Curiosity Nano Explorer, the pins on the I2C I/O Expander 1 are connected to active-low LEDs, while the pins on the I2C I/O Expander 2 are connected to buttons (SW1, SW2 and SW3) as well as the joystick inputs (left, right, up, down, press).

This example configures the I/O Expander 1 pins as outputs set LOW, so the active-low LEDs are initially all turned on. The I/O Expander 2 pins are configured as digital inputs. As a button press or joystick input is detected, the associated LED is turned off. The Curiosity Nano's SW is configured as a reset, turning on all the LEDs again.

Operation

When running the application using the MPLAB® Data Visualizer, you should see something similar to the following:

When running the application, using the MPLAB Data Visualizer, you should see something similar to the following: alt text Note: Behaviour is not as reliable as in the Callbacks version.

Note: Debug I/O is not actively used. However, since the SW pin on the Curiosity Nano is a Debug I/O pin, so when pushing the IO_Reset, a toggle is picked up on the Debug I/O pin.

Setup

The image below outlines the complete MPLAB Code Configurator (MCC) Melody configuration, including all the selected tasks implemented in this example, as seen in the MCC Melody Builder.

alt text

alt text

MCC Melody Example Components

Example Components are a tight integration of learning material directly into MCC. This allows users to conveniently place the configuration instructions side-by-side to the components they are configuring. For more information, refer to the MCC Melody Example Components introduction.

Related Documentation

Software Used

  • MPLAB® X IDE v6.25 or newer

  • MPLAB® XC8 v3.00 or newer

  • MPLAB® Code Configurator (MCC) Plug-in Version v5.6.2 or newer (Tools>Plugins>Installed, search: "MCC")

  • MPLAB® Data Visualizer Plug-in Version v1.4.1926 or newer (Tools>Plugins>Installed, search: "Data Visualizer")

  • MCC Melody I2C_Host Example Component for the Curiosity Nano Explorer 1.0.0 or newer

  • MCC Core v5.8.2 or newer

  • Single Page Application (SPA) Host v1.0.0 or newer

  • MCC Melody Core v2.9.1 or newer

Open the MCC Content Manager CM_icon to verify the MCC Core and MCC Melody Core versions.

alt text

Hardware Used

About

I/O Expander 1 pins (8 LEDs) set as outputs, low (LEDs on). I/O Expander 2 pins (SW1-3, 5 joystick inputs) as digital inputs. Button/joystick turns LED off. Curiosity Nano SW resets LEDs on.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •