element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Frederick Vandenbosch's Blog Cypress CY8CKIT-059 PSoC 5LP Prototyping Kit - 16x2 Character LCD
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fvan
  • Date Created: 1 Jul 2015 7:00 PM Date Created
  • Views 6043 views
  • Likes 7 likes
  • Comments 11 comments
  • RoadTest
  • cy8ckit-059
  • prototyping
  • review
  • guide
  • kit
  • cypress
  • psoc5lp
  • psoc
Related
Recommended

Cypress CY8CKIT-059 PSoC 5LP Prototyping Kit - 16x2 Character LCD

fvan
fvan
1 Jul 2015

I'm still experimenting in the scope of the Cypress CY8CKIT-058 PSoC 5LP Prototyping Kit RoadTest. This time, I experimented with a 16x2 LCD display.

 

Character LCD

 

Simple 16x2 character LCDs provide an easy way of visualising textual and numerical data, such as sensor data.

 

Workspace

 

Rather than starting from scratch and having to figure out every aspect of controlling a character LCD, it's possible to load an example, try to understand the example, verify it works and start making modifications to it.

 

To load the example workspace, go to "File > Example Project ...". In the popup, enter "LCD" as a search criteria for project name. This should leave a few projects to pick from. Pick "CharLCD_CustomFont".

Finally, once the project is loaded, right-click the project name and select "Device Selector ...". In the popup, make sure to select the device that matches yours.

 

imageimage

 

You can then proceed to build the project and program your device.

 

Connections

 

The connections required for the LCD are specified in the datasheet, which can be accessed by right-clicking the "Character LCD" component and selecting "Open Datasheet ...".

 

imageimage

 

Test

 

If the kit was programmed successfully and the connections to the LCD are correct, the following should appear:

image

 

The top row are a bunch of custom characters spelling out the word "CYPRESS", the bottom row is the string "Perform".

The custom characters can be modified by double-clicking the "Character LCD" component in the TopDesign.

 

Modifications

 

Once the sample code is working properly, it is of course possible to modify it.

 

My first modification was to display two different strings statically, including two custom characters. This is the code:

 

#include <device.h>

extern uint8 const CYCODE LCD_customFonts[];

void main() {

  LCD_Start();
  LCD_LoadCustomFonts(LCD_customFonts);

  LCD_Position(0u, 0u); // first row, first position
  LCD_PrintString("element14");

  LCD_Position(1u, 9u); // second row, ninth position
  LCD_PrintString("Cypress");

  LCD_Position(0u, 10u);
  LCD_PutChar(LCD_CUSTOM_1);

  LCD_Position(1u, 7u);
  LCD_PutChar(LCD_CUSTOM_0);

  CyDelay(200u);

  for(;;) {}
}

 

And the result:

image

 

The previous modification is static. it displays the strings of text and leaves them as is.

 

To have a more dynamic example, I combined the LCD with the CapSense slider I created in the previous post (Cypress CY8CKIT-059 PSoC 5LP Prototyping Kit - CapSense Linear Slider) to control the LCD's backlight and report the brightness.

The LCD's anode pin is now connected to a digital output pin controlled by a PWM signal. The PWM signal's duty cycle is controlled by the CapSense slider, making it possible to change the brightness of the backlight.

 

The code:

 

#include <device.h>
#include <stdio.h>

#define NO_SLIDE 0xFFFFu

extern uint8 const CYCODE LCD_customFonts[];

void main() {

  uint16 SliderPos = NO_SLIDE;
  uint16 LastPos = NO_SLIDE;
  char SliderPosString[3];

  // PWM initialisation and start
  PWM_1_Start();
  Clock_1_Start();

  // LCD initialisation and start
  LCD_Start();
  LCD_LoadCustomFonts(LCD_customFonts);

  // CapSense related initialisation and start
  CyGlobalIntEnable;
  CapSense_1_Start();
  CapSense_1_InitializeAllBaselines();

  // Display a startup message for two seconds
  LCD_Position(0u, 0u); // first row, first position
  LCD_PrintString("element14");

  LCD_Position(1u, 9u); // second row, ninth position
  LCD_PrintString("Cypress");

  LCD_Position(0u, 10u);
  LCD_PutChar(LCD_CUSTOM_1);

  LCD_Position(1u, 7u);
  LCD_PutChar(LCD_CUSTOM_0);

  CyDelay(2000u);

  // Clear the startup message
  LCD_ClearDisplay();

  // Display the static part of the text
  LCD_Position(0u, 0u); // first row, first position
  LCD_PrintString("LCD Brightness");

  LCD_Position(1u, 0u);
  LCD_PrintString("0..255: ");

  for(;;) {
    CapSense_1_UpdateEnabledBaselines();
    CapSense_1_ScanEnabledWidgets();

    while(CapSense_1_IsBusy());

    SliderPos = CapSense_1_GetCentroidPos(CapSense_1_LINEARSLIDER0__LS);

    if(SliderPos != NO_SLIDE && SliderPos != LastPos) {
        PWM_1_WriteCompare(SliderPos);
        // Convert the SliderPos to String, add leading 0's if needed
        sprintf(SliderPosString, "%03i", SliderPos);
        // Display the dynamic part of the text
        LCD_Position(1u, 13u);
        LCD_PrintString(SliderPosString);
    }
  }
}

 

imageimageimageimage

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

I've attached the workspace bundle containing the code, topdesign, etc ... to this post.

Attachments:
CharLCD_CustomFont02.cywrk.Archive01.zip
  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 10 years ago in reply to Former Member +2
    These boards have a debugger/programmer on board. When you install the Cypress software, it also installs the drivers for that. You connect the board to your computer with an USB, build your project, and…
  • mcb1
    mcb1 over 10 years ago +1
    Very useful .... I'm glad we have you on point blazing the trail for us 'paying tourists' to drive down. Mark
  • DAB
    DAB over 10 years ago +1
    Nice detailed post. I need to power up one of my Psoc boards and try this out. DAB
Parents
  • Former Member
    Former Member over 10 years ago

    Hi! Awesome post, could you explain what that blue square is on the top right? and what the white board is called? Thanks! super new at this stuff

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to Former Member

    blue thing: trim potentiometer

    white thing: breadboard

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to Former Member

    blue thing: trim potentiometer

    white thing: breadboard

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • Former Member
    Former Member over 10 years ago in reply to Jan Cumps

    Thanks! Once you have the code set up how do you load it onto the device?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to Former Member

    These boards have a debugger/programmer on board. When you  install the Cypress software, it also installs the drivers for that.

    You connect the board to your computer with an USB, build your project, and load the code to the device.

    You can then step through the code, set breakpoints, look at variables and registers.

     

    This is true for many development boards.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Jan Cumps

    Got it, thanks for the info, got it to work! =D

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube