In this project, we'll create an application using the CY8CKIT-050 PSoC 5LP development kit to control an LED using an interrupt. The LED will blink for 0.9s every second when a button is pressed, and stop blinking when another button is pressed. This experiment helps you understand how to use interrupts in PSoC Creator.
PSoC schematic diagram
The controlling LED with an interrupt project needs the following parts:
CY8CKIT-050 PSoC 5LP Development Kit
USB Cable
Two Push Buttons
Project Creation:
Open PSoC Creator.
Go to File > New > Project.
Choose the target device: PSoC5LP CY8CKIT-050 (CY8C5868AXI-LP035 chip).
Select "Empty Schematic" and name the project Interrupt_LED.
Hardware Configuration:
Go to the Component Catalog on the right side of the screen, search for the following components and drag them to the TopDesign schematic:
PWM
Clock
Logic Low
Digital Input Pin (twice)
Interrupt (twice)
Digital Output Pin
Component Configuration:
Double-click on the Digital Input Pin, rename it to "SW2", set the drive mode to Resistive Pull Up, and set the Interrupt mode to Falling edge.
Double-click on the second Digital Input Pin, rename it to "SW3", set the drive mode to Resistive Pull Up, and set the Interrupt mode to Falling edge.
Double-click on the Digital Output Pin, rename it to "LED", choose Strong Drive mode, and set the initial drive state to High.
Double-click on the Clock component and set the frequency to 100 Hz with ±5% tolerance.
Double-click on the PWM component, rename it to PWM, set the PWM mode to one output, set the period to 99, and CMPvalue1 to 90.
In the workspace explorer, double-click on Pins under Interrupt_LED.cydwr and set Port to P6[1] for SW2, P15[5] for SW3, and P6[3] for LED.
Change the names of the interrupt components to "SW2_Int" and "SW3_Int".
Programming and Results:
Double-click on main.c in the workspace explorer under source files.
Add the code to control the LED with interrupts
Build the design by clicking on "Build" or pressing Shift+F6.
Verify and resolve any warnings or errors.
Connect the PSoC 5LP to your computer using the USB cable.
Click on "Program" or press Ctrl+F5 to upload the code to the PSoC.
Press the SW2 button to start the LED blinking and press the SW3 button to stop the blinking.
Code for main.c
PSoC real-life implementation