In this project, we'll build an application using the CY8CKIT-050 PSoC 5LP development kit to light an LED using a potentiometer and ADC (Analog-to-Digital Converter). The LED will light up when the potentiometer is at the maximum position. Additionally, the state of the LED will be displayed on an LCD. This experiment helps you understand how to use ADC and digital output pins in PSoC Creator.
PSoC schematic diagram
The maximal value indicator (with ADC) project needs the following parts:
CY8CKIT-050 PSoC 5LP Development Kit
USB Cable
Potentiometer
LED
Character LCD Display
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 ADC_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:
SAR ADC
Analog Pin
Digital Output Pin
Character LCD
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", choose Strong Drive mode, uncheck HW connection, and set the initial drive state to Low.
Double-click on the ADC component, rename it to "ADC", set the resolution to 8 bits, the conversion rate to 100000, the input range to Vssa to Vdda (Single Ended), and choose internal Vref as the reference source.
Double-click on the LCD component and set it up as a 2x16 character display.
In the workspace explorer, double-click on Pins under ADC_LED.cydwr and set Port to P6[3] for LED, P6[5] for Potar, and P2[6:0] for the LCD.
Programming and Results:
Double-click on main.c in the workspace explorer under source files.
Add the code to enable the ADC 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 and display the state on the LCD.
Code for main.c
PSoC real-life implementation