2 push buttons and leds – Digilent 410-295P-KIT User Manual
Page 11

ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 11 of 37
On the ChipKIT Pro MX4, pin numbers 0–71 are used to access the pins on the Pmod connectors and pin numbers
72 and 73 are used for the two signal pins on the I
2
C connector, J6. The pin numbers are assigned so that
connector JA pin 1 (JA-01) is digital pin 0, JA pin 2 (JA-02) is digital pin 1, and so on.
Pins 0-7 are on connector JA, pins 8-15 on JB, pins 16-23 on JC, pins 24-31 and so on. Refer to the tables in
Appendix C for detailed information about the pin mapping between Pmod connector, logical pin number, and
PIC32 microcontroller pin number and pin function.
When using the ChipKIT Pro MX4 with the MPIDE the functions pinMode(), digitalRead(), and digitalWrite() are
used for digital pin I/O.
The pinMode() function is used to set the pin direction. Pin direction can be set to: INPUT, OUTPUT, or OPEN.
OPEN is used for open-drain and implies output.
The digitalRead() and digitalWrite() functions are used to read or write the pins. DigitalRead() returns the current
state of the specified pin, and digitalWrite is used to set the state of an output pin.
5.1 PIC32MX460 Pin 20
Pin 20 on the PIC32MX460 has multiple functions. It provides the VBUSON signal when the board is being used to
implement a USB host. It also provides the positive input for analog comparator 1, analog to digital converter input
AN5, change notice interrupt CN7 and bit 5 of general I/O Port B. In order to support all of these different
functions, jumper block J16 is used to select the routing of this pin.
Normally, the shorting block will be in the JJ-8 position. This connects microcontroller pin 20 to Pmod connector JJ
pin 8. This allows the use of most functions of this pin.
When the board is being used as a USB host, the shorting block is placed in the VBUSON position to allow use of
the VBUSON signal to control power to the USB bus.
Placing the shorting block in the DAC position connects the output of IC3, the MCP4725 digital to analog converter
to microcontroller pin 20. This allows the DAC output to be used as a programmable reference for analog
comparator 1.
5.2 Push Buttons and LEDs
The ChipKIT Pro MX4 board provides two push button switches for user input and four LEDs for output. The
buttons, BTN1 and BTN2 are connected to I/O pins TRCLK/RA6 and TRD3/RA7 respectively. To read the buttons,
pins 6 and 7 of I/O Port A must be configured as inputs by setting the corresponding bits in the TRISA register. The
button state is then obtained by reading the PORTA register. When a button is pressed, the corresponding bit will
be high (‘1’). Note that the microcontroller pins used by the buttons are shared with pins 3 & 4 of Pmod connector
JF. Note that the button circuitry will effectively act as a 10K ohm pull-up resistor when the button is pressed and a
20K ohm pull-down resistor when the button is not pressed. This will not interfere with most normal uses of the
I/O pins if the buttons are not being used.
The four LEDs are connected to bits 10-13 of I/O Port B. LED 1 is connected to bit 10, LED 2 is connected to bit 11,
and so on. These four bits are also shared with pins 1-4 of Pmod connector JK. To use the LEDs, set the desired
bits as outputs by clearing the corresponding bits in the TRISB register. The state of an LED is set by writing values
to the LATB register. Setting a bit to 1 will illuminate the LED and setting the bit to 0 will turn it off.
When using the MPIDE and the chipKIT system, the buttons are accessed using digitalRead() and the LEDs using
digitalWrite(). Use the following pins to access them: