In this project, we'll build an application using the CY8CKIT-050 PSoC 5LP development kit to light an LED using a potentiometer. The LED will light up when the potentiometer is at the maximum position. This experiment helps you understand how to use a comparator and analog input pins in PSoC Creator.
PSoC schematic diagram
The maximal value indicator (with comparator) project needs the following parts:
CY8CKIT-050 PSoC 5LP Development Kit
USB Cable
Potentiometer
LED
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 Comp_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:
Comparator
Analog Pin
Digital Output Pin
VRef
Component Configuration:
Double-click on the Analog Input Pin, rename it to "Potar", and choose High Impedance Analog drive mode.
Double-click on the Digital Output Pin, rename it to "LED", and choose Strong Drive mode.
Double-click on the Comparator, rename it to "Comp", disable Hysteresis, set the speed to Fast, and set sync to Bypass.
Double-click on the VRef component and set the value to Vdda.
In the workspace explorer, double-click on Pins under Comp_LED.cydwr and set Port to P6[3] for the LED and P6[5] for the Potentiometer.
Programming and Results:
Double-click on main.c in the workspace explorer under source files.
Add the code to enable the comparator and light the LED when the potentiometer is at the maximum position.
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.
Turn the potentiometer to see the LED light up at the maximum position.
Code for main.c
PSoC real-life implementation