PSoC™ 6S2 GPIO-HAL LED Blink Lab

Lab Objective:

The objective of this lab is to familiarize students with the basic concepts of GPIO (General Purpose Input Output) using a PSoC 6 microcontroller from Cypress (CY8CKIT-062S2-43012 Infineon Board). By the end of this lab, students should be able to initialize GPIOs, manipulate GPIO states, and create basic delay functions.

Lab Description:

In this lab, students will be tasked with programming a PSoC 6 microcontroller to control an LED through a GPIO. The LED will be made to blink at a regular interval, demonstrating basic GPIO output functionality.

The code will:

  1. Initialize the board and all necessary peripherals.

  2. Initialize a GPIO pin (connected to the LED) as an output.

  3. Create an infinite loop where it:

    • Drives the LED GPIO pin low, turning the LED on.

    • Waits for 250 milliseconds.

    • Drives the LED GPIO pin high, turning the LED off.

    • Waits for another 250 milliseconds. This sequence will result in the LED blinking on and off every 250 milliseconds.

🔥 Requirements




ModusToolbox™ software v3.0 or later

CY8CKIT-062S2-43012 Infineon Board

Technical Report

🚩 Let start

Create Application

  • 👉 Open Eclipse IDE ModusToolbox

  • 👉 Select Board

  • 👉 Select Application


  • 👉 Add Code to the main() in main.c file:

// Add loop
for (;;)
  	 /* Drive CYBSP_USER_LED low (LED on) */
	cyhal_gpio_write(CYBSP_USER_LED, 0);

	/* Wait 250 ms */

	/* Drive CYBSP_USER_LED high (LED off) */
	cyhal_gpio_write(CYBSP_USER_LED, 1);

	/* Wait 250 ms */
  • for (;;) { ... }: This is an infinite loop. Everything within this loop will be repeated indefinitely. This is common in embedded systems where the program is meant to run until the device is powered off.

  • cyhal_gpio_write(CYBSP_USER_LED, 0);: This sets the state of the CYBSP_USER_LED GPIO pin to low (0 volts), which typically turns the LED on.

  • cyhal_system_delay_ms(250);: This waits for 250 milliseconds.

  • cyhal_gpio_write(CYBSP_USER_LED, 1);: This sets the state of the CYBSP_USER_LED GPIO pin to high (usually 3.3 or 5 volts, depending on the microcontroller), which typically turns the LED off.

  • cyhal_system_delay_ms(250);: This waits for another 250 milliseconds.

This sequence makes the LED blink - it will be on for a quarter of a second, then off for a quarter of a second, continuously.

Build the Application

  • 👉 Build Application

Launching the Application

  • 👉 Launching Program

    • Before launching the program to the board, make sure that you have already connected the board to the computer through a USB cable.

    • Launching Program

  • 👉 Check the Result

🎉 Congratulations! You can now complete Lab101

Supported toolchains (make variable 'TOOLCHAIN')

  • GNU Arm® embedded compiler v10.3.1 (GCC_ARM) - Default value of TOOLCHAIN

  • Arm® compiler v6.16 (ARM)

  • IAR C/C++ compiler v9.30.1 (IAR)

Supported kits (make variable 'TARGET')


ModusToolbox™ Software Training

Other resources

Infineon provides a wealth of data at to help you select the right device, and quickly and effectively integrate it into your design.

Document history

Document title: BILL_MTB-101GPIO LED Blink Template

VersionDescription of change


Lab101: Introduction to GPIO control with PSoC 6, featuring an LED blinking .


  • Assoc. Prof. Wiroon Sriborrirux

  • Mr. Sriengchhun Chheang

  • Mr. Sabol Socare

© BDH Corporation, 2022-2023

Last updated

Assoc. Prof. Wiroon Sriborrirux, Founder of Advance Innovation Center (AIC) and Bangsaen Design House (BDH), Electrical Engineering Department, Faculty of Engineering, Burapha University