This example demonstrates how to read/write GPIO pin values of Arduino Uno board from host computer through serial communication. Even through this test example uses Arduino Uno board, same procedure can be adopted for other Arduino series micro-controller boards supported by CASP.
Pre-Requisites
- Arduino Uno R3 board with a USB cable.
- CASP software is installed and functional.
- Arduino BSP is installed.
- The project files are located at CASP installed directory ‘CASP/support/examples/casp_gpio_examples/arduino_boards/casp_gpio_uno_nano_leonardo_serial’. These are also available for download at this link.
Programming the Board
Before starting this example, the target board should be programmed with binary file that enables CASP GPIO communication protocol. Please follow below steps to program the target board with the binary file that enables CASP GPIO communication protocol.
- Connect Arduino Uno board to the USB of the computer
- Run CASP and click on Tools > Programmer

- It opens a programmer dialog box. Set board as ‘Arduino Uno’, programmer as Programme0, select serial port to which the board is connected and select the binary file from CASP installed directory ‘CASP/support/examples/casp_gpio_examples/arduino_boards/casp_gpio_uno_nano_leonardo_serial/bin/casp_gpio_uno.hex’
- Click ’Program’ button to program the board with the above selected binary file. Screen shot is shown below.

Accessing GPIO from CASP running on host computer
- Start CASP program and open the example project from ‘examples/test_examples’ directory. It is also available for download at this link..
- The project model consists of some displays, plots and controls to display and control the GPIO pins of the board.

- Open ‘Configure Simulation IO’ window from ‘Configure Simulation IO’ menu item

- In the ‘Configure Simulation IO’ window do the following in sequence to connect to the board and mirror the GPIO pin data of the board

- From the above window, once the board is connected and on-line data is updating, save and close the window. The step indicates that the board is detectable and its GPIOs can be mapped.
- The model can be modified as per your logic. Documentation on GPIO pin mapping is available at ‘CASP/support/examples/casp_gpio_examples/arduino_boards/casp_gpio_uno_nano_leonardo_serial/doc/index.htm’
- Since, rest of the model is ready, click Run button to start simulation. The simulation should start communicating with the board’s GPIO pins. Below is the screen short of simulation panel window. Try using simulation panel controls to control on-board LED, PWM and servo parameters.

