Shahariar
Published © GPL3+

PSoC 4 : Making a 8 Pin Cap Slider for CY8CKIT-049 4200 Kit

Make your own Cheap Capacitive Slider with Low cost materials for PSoC4 CY8CKIT-049 4200 Kit using Copper Tape, Male Header on Plywood board

BeginnerShowcase (no instructions)1,387
PSoC 4 : Making a 8 Pin Cap Slider for CY8CKIT-049 4200 Kit

Things used in this project

Hardware components

SparkFun Copper Tape (or Aluminum Foil paper)
×1
SparkFun Long Male Header
×1
SparkFun Ribbon (Rainbow) Cable
×1

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Drill motor or Niddle

Story

Read more

Schematics

Cypress Files

Modified version of Cypress PSoC Creator Cap Sense Example !

Capacitive Slider Drawing

Connecting Cap Slider with CY8C-049 kit !

LCD Horizontal Bar Graph with Capacitive Slider, PSoC Rocks !

Code

PSoC 4 Cap Sense

C/C++
/*******************************************************************************
* File Name: main.c
*
* Version: 1.10
*
* Description:
*  The project explains the usage of CapSense CSD component. The 2 buttons and
*  linear sliders are used as sensing elements. LED displays buttons active 
*  state and slider position is shown on LCD.
*
********************************************************************************
* Copyright 2013, Cypress Semiconductor Corporation. All rights reserved.
* This software is owned by Cypress Semiconductor Corporation and is protected
* by and subject to worldwide patent and copyright laws and treaties.
* Therefore, you may use this software only as provided in the license agreement
* accompanying the software package from which you obtained this software.
* CYPRESS AND ITS SUPPLIERS MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* WITH REGARD TO THIS SOFTWARE, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*******************************************************************************

****** THIS PROGRAM is an example code provided by Cypress, I only modified some lines
*****   to work with my Capacitive Silder Input 
*/
#include <device.h>


/*******This part is modified by Shahariar***********/

 // In Capsense CSD component CapSense Slider resoluton is set to 80 
 //Since LCD has 16x5= 80 bar resolution, 
/************************************************/

//
uint16 curPos, oldPos;

/*******************************************************************************
* Function Name: main
********************************************************************************
* Summary:
*  Main function performs following functions:
*   1. Enable global interrupts.
*   2. Initialize CapSense CSD and Start the sensor scanning loop.
*   3. Process scanning results and display it on with LEDs.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
int main()
{
    /* Enable global interrupts */
    CyGlobalIntEnable;

    // Power Up and On Backlight
    

/*******This part is modified by Shahariar***********/

    LCD_Vdd_Write(1);
    Back_LightP_Write(1);
    Back_LightN_Write(0);
    
    /* Start LCD and CapSense components */
    LCD_Start();
/************************************************/

    CapSense_CSD_Start();	

    /* Initialize baselines */ 
    CapSense_CSD_InitializeAllBaselines();
    
    while(1u)
    {
        /* Update all baselines */
        CapSense_CSD_UpdateEnabledBaselines();
        
   		/* Start scanning all enabled sensors */
    	CapSense_CSD_ScanEnabledWidgets();
    
        /* Wait for scanning to complete */
		while(CapSense_CSD_IsBusy() != 0);
        {}
		/* Display CapSense state using LEDs */
        CapSense_DisplayState();
    }
}

/*******************************************************************************
* Function Name: CapSense_DisplayState
********************************************************************************
* Summary:
*  Changes LEDs brightness by changing the duty cycle of PWM signals.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
void CapSense_DisplayState(void)
{
    /* Find Slider Position */
    curPos = CapSense_CSD_GetCentroidPos(CapSense_CSD_LINEARSLIDER0__LS);    
    
    /* Reset position */
    if(curPos == 0xFFFFu)
    {
        curPos = 0u;
    }
                
    /* Move bargraph */
    if (curPos != oldPos)
    {
        oldPos = curPos;
        /* Display Slider bargraph */
        if (curPos != 0u)
        {


/*******This part is modified by Shahariar***********/

           LCD_DrawHorizontalBG(1,0,80,curPos);
        }        
    }
}


/* [] END OF FILE */

Credits

Shahariar

Shahariar

47 projects • 152 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments