This is a demo project for the Pmod JSTK2 made by Digilent. The X axis and Y axis values of the joystick position are measured and displayed on the Serial monitor with option to normalize these values (standard: ranges from 0 to 1023 - normalized: ranges from -1 to +1). To control the Pmod, an Arduino UNO is used, which also sends the data to the computer. To communicate with the peripheral device, SPI communication protocol is used, in mode 0, with a serial clock frequency between 1MHz and 4MHz. Data is send in 5 bytes: X_LSB, X_MSB (10-bit value with 6 leading zeros), Y_LSB, Y_MSB (10-bit value with 6 leading zeros) abd button state (the last two bits mark the two buttons). The RGB LED state is also controlled with SPI protocol by sending first the address of the LED (0x84) followed by the duty cycle for red, green and blue colors. The LED will stay lit for a few seconds after a button is pressed (the color depends on which button was pressed).
Output of the Pmod JSTK2 test program with normalized values